Advertisement
Mastercpp

fibonacci

Nov 6th, 2015
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.25 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main(){
  5.  
  6.     int numero =1,penultimo=0,ultimo=0;
  7.    
  8.     for(int i =0; i<30; i++){
  9.         penultimo = ultimo;
  10.         ultimo = numero;
  11.         numero = penultimo+ultimo;
  12.         cout << "  " << numero;
  13.     }
  14.  
  15.     cin.get();
  16.     return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement