Advertisement
Guest User

Untitled

a guest
Oct 19th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. main()
  6. {
  7. int n, w, w1=0, w2=1, k=2;
  8.  
  9. cin >> n;
  10. if(n<=1) w=n;
  11. else
  12. {
  13. while(k<=n)
  14. {
  15. w=w1+w2;
  16. w1=w2;
  17. w2=w;
  18. k+=1;
  19. }
  20. }
  21. cout << w;
  22.  
  23. return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement