Cod sursa(job #2155780)
Utilizator | Data | 8 martie 2018 09:17:58 | |
---|---|---|---|
Problema | Al k-lea termen Fibonacci | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.29 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("kfib.in");
ofstream g("kfib.out");
long long k,a,b,c,i;
int fib(long long n)
{
if (n==1 || n==2) return 1;
else return(fib(n-1)+fib(n-2));
}
int main()
{
f>>k;
g<<fib(k);
return 0;
}