Advertisement
Abelsor

S3_Ejercicio_6

Feb 23rd, 2023 (edited)
944
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.26 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main(){
  4.     int n;
  5.     cin>>n;
  6.    
  7.     int tn = 1;
  8.     int tn_1 = 0;
  9.     int tn_2 = 0;
  10.    
  11.     for(int i=1 ; i<=n ; i++){
  12.        
  13.         tn_2 = tn_1;
  14.         tn_1 = tn;
  15.        
  16.         tn = tn_2 + tn_1;
  17.     }
  18.    
  19.     cout<<tn;
  20.    
  21.     return 0;
  22. }
  23.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement