Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- int a,b;
- int fibonacci(int n)
- {
- int a=2;
- int c;
- if(n==0)
- {
- return 0;
- }
- if(n==1)
- {
- return 1;
- }
- int c1=0;
- int c2=1;
- while(a<=n)
- {
- c=c1+c2;
- c1=c2;
- c2=c;
- a++;
- }
- return c;
- }
- int main()
- {
- cout << "Podaj liczbe"<<endl;
- cin >> a;
- cout << fibonacci(a)<<endl;
- cout << "Liczba 55"<<endl;
- cout << fibonacci(55)<<endl;
- cout << "Liczba 25"<<endl;
- cout << fibonacci(25)<<endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment