Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- int x;
- scanf("%d",&x);
- printf("There is(are) %d way(s).",fibo(x));
- return 0;
- }
- int fibo(int x)
- {
- int a = 1;
- int b = 2;
- int count = 0;
- int sum;
- if(x==1 || x==2) return x;
- else
- {
- while(count!=x-2)
- {
- sum = a+b;
- a = b;
- b = sum;
- count += 1;
- }
- return sum;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement