Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How would i write this in C language remember it cannot use division. Write a pr

ID: 3650986 • Letter: H

Question

How would i write this in C language remember it cannot use division.
Write a program to find and print a Fibonacci sequence of numbers. The Fibonacci sequence is
defined 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

Explanation / Answer

#include int main() { A: int n; printf(" Enter a limit on the largest number to be displayed: "); scanf("%d",&n); if(n=f+s) { printf(" %d",f+s); int temp=f+s; f=s; s=temp; } printf(" "); int count=1; int l=s; while((s>>1)!=0) { if((s>>1)*2==s) { count*=2; s=s>>1; } else break; } if(count==1) printf("The last number %d is divisible by 1 ",l); else printf("The last number %d is divisible by %d ",l,count); } char ch; scanf("%c",&ch); printf("Do you want to print a different sequence (Y/N): "); scanf("%c",&ch); if(ch=='N') return 0; else goto A; }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote