fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int p=1,c=1,r;
  6. int n;
  7. while(cin>>n){
  8. for(int i=2;i<n;i++){
  9. r=p+c;
  10. p=c;
  11. c=r;
  12. }
  13.  
  14. cout<<r<<"\n";
  15. }
  16. return 0;
  17. }
Success #stdin #stdout 0s 5548KB
stdin
5
3
11
7
5
500
stdout
5
8
610
6765
28657
1218555693