Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Autor: Carlos Andres Delgado
- * Nombre: fibunacci.cpp
- * Descripción: Soluciona la serie de fibunnaci de forma iterativa
- * Fecha: 02-Septiembre-2016
- */
- #include <iostream>
- using namespace std;
- int main(){
- int faa = 0; //f(0)
- int fa = 1; //f(1)
- int f = faa + fa; //f(2)
- cout << "f(0)" << faa << endl;
- cout << "f(1)" << fa << endl;
- cout << "f(2)" << f << endl;
- for(int i=3; i<=100; i++){
- faa = fa; // f(i-2)
- fa = f; // f(i-1)
- f = faa + fa; //f(i)
- cout << "f(" << i << ") " << f <<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement