Cod sursa(job #1318250)

Utilizator AndreiMedarMedar Andrei AndreiMedar Data 15 ianuarie 2015 19:42:02
Problema Al k-lea termen Fibonacci Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.24 kb
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
ifstream f("kfib.in");
ofstream g("kfib.out");
int x,a,b,n;
f>>n;
a=0;
b=1;
for(int i=2;i<=n;i++)
{
    x=b;
    b=a+b;
    a=x;
}
g<<b;
    return 0;
}