Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- main()
- {
- int n, w, w1=0, w2=1, k=2;
- cin >> n;
- if(n<=1) w=n;
- else
- {
- while(k<=n)
- {
- w=w1+w2;
- w1=w2;
- w2=w;
- k+=1;
- }
- }
- cout << w;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement