Cod sursa(job #2265503)
Utilizator | Data | 21 octombrie 2018 12:13:05 | |
---|---|---|---|
Problema | Al k-lea termen Fibonacci | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int n,f1=0,f2=1,f3,cont=1;
ifstream f("kfib.in");
ofstream g("kfib.out");
f>>n;
f.close();
while(cont<n)
{
f3=f1+f2;
f1=f2;
f2=f3;
cont=cont+1;
}
cout<<f3;
g.close();
return 0;
}