Write a program to find and print a Fibonacci sequence of numbers. The Fibonacci
ID: 3650997 • Letter: W
Question
Write a program to find and print a Fibonacci sequence of numbers. The Fibonacci sequence isdefined as follows:
Fn = Fn-2 + Fn-1,n >= 2,where F0 = 0,F1 = 1
Your program should prompt the user to enter a limit, print the sequence up to the limit, and then
indicate what is the greatest power of 2 that the final number printed is divisible by. Note: You
are NOT allowed to use the divide function.
Here is what the user will see when the program is executed:
This program prints the Fibonacci sequence
Enter a limit on the largest number to be displayed: 50
1 1 2 3 5 8 13 21 34
The last number 34 is divisible by 2.
Do you want to print a different sequence (Y/N): y
Enter a limit on the largest number to be displayed: 200
1 1 2 3 5 8 13 21 34 55 89 144
The last number 144 is divisible by 16.
Do you want to print a different sequence (Y/N): n
Explanation / Answer
#include#include#include void main() { int limit,f0,f1,fn, last_no,i,temp; char ch='y'; clrscr(); printf(" This program prints the Fibonacci sequence"); do{ f0=0,f1=1,fn=0,temp=0,last_no=0; i=0; printf(" Enter a limit on the largest number to be displayed :"); scanf("%d",&limit); printf("%d ",f1); fn=f0+f1; for(;fn
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.