Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int FIBONACCI(int l)
- {
- int a, b;
- if(l == 0) return 0;
- a = 0; b = 1;
- for(int i=0; i < (l-1); i++)
- {
- swap(a, b);
- b += a;
- }
- return b;
- }
- int main()
- {
- int liczba;
- cout << "Podaj liczbe: ";
- cin>>liczba;
- cout<<"Wartosc ciagu FIBONACCIego dla tej liczby wynosi : ";
- cout<<FIBONACCI(liczba)<<endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment