Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 2 of 2. Fibonacci Sequence (50 marks] Write a C++ program which will ask the user to input an integer number N. Your program

image text in transcribed
Question 2 of 2. Fibonacci Sequence (50 marks] Write a C++ program which will ask the user to input an integer number N. Your program should print the first numbers in the Finaci 3 Fibonacci sequence are a series of numbers where each number is the sum of the two preceding ones, starting from and F (0) -0,F (1)-1 F (n)-F (-1)+F (-2) The beginning of the sequence would then be 0.1, 1.2.3.5.& 13.21.34, 55, 89.... We do not need arrays for this problem. We need loops. We can display this sequence each number at a time, by computing the sum of the previous two numbers in each iteration of the loop. The old previous numbers are then updated to include the news we just computed. This now sum and the previous number can now be used to print the next number in the Fibonacci sequence Given a user input number N print the first N umbers in the series. Print the first 6 numbers in the Fibonacci sequence Example: Input N-6. Output: 0,1,1,2,3, Print the first nubes in the Fibonacci sequence Example: Input: N- & Output: 0.1.1.2.3.5.& 13 Print the first I numbers in the Fibonacci sequence. Example: Input: N-15. Output: 0,1,1,2,1.5.& 13. 21. 34, 55, 89, 144, 233, 377 Print the first 25 mmbers in the Fibonacci sequence Example: Input: N-25. Output: 0.1.1.2.3.5.& 13.21.34, 55, 89, 144.233.377,610, 987, 1597,2584,4181,6765, 1 6, 1771128657, 46368 Make sure your code works for any input number, not just the test cases. Your code will be tested on other test cases not listed here. Please properly come your code before submission For this part of the assignment, name your source file as Fibonacci WSUID.cpp. For example, if your user ID is A999999 name your file as Fibonacci A999999.cpp Sample test cases are provided in the next page CS211 Homework - 2 Sample Test cases Tetravel Input Enter Fibonacci numbers required: Test.se 2: Inpati Enter Fibonacci numbers required: 17 0,1,1,2,3,SR, 13 1.1.2.3.5, 377.610,957, 13, 21, 14,55,89, 144.233. Tetas Test avec Enter Fibonacci numbers required: 3 Enter Fibonacci numbers required: 10 Output Output 0.1.1.2.1.5, , 13,21,34 HINTS Think about the problem before you start coding Keep a count of how many numbers have been printed so far. Stop your loop when N numbers are printed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Implementing Ai And Machine Learning For Business Optimization

Authors: Robert K Wiley

1st Edition

B0CPQJW72N, 979-8870675855

More Books

Students also viewed these Databases questions

Question

What is cost-plus pricing?

Answered: 1 week ago

Question

Draft a proposal for a risk assessment exercise.

Answered: 1 week ago