Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // In ra day so fibonaci
- // Khai bao cac ham thu vien neu co
- #include<stdio.h>
- #include<conio.h>
- long fibo(int n);
- void main()
- {
- int n;
- scanf("%d",&n);
- printf("%ld\t",fibo(n));
- }
- long fibo(int n)
- {
- long f=0;
- long f1=1;
- long f2=1;
- if(n==2)
- return f1;
- else
- {
- for(int i=3;i<=n;i++)
- {
- f=f1+f2;
- f1=f2;
- f2=f;
- }
- return f;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement