Cod sursa(job #3298911)
Utilizator | Data | 2 iunie 2025 23:49:59 | |
---|---|---|---|
Problema | Al k-lea termen Fibonacci | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
ifstream fin("kfib.in");
ofstream fout("kfib.out");
int main()
{
int f1,f2,K;
long long fk;
fin>>K;
f1=0;
f2=1;
fk=(pow((1+sqrt(5))/2,K)-pow((1-sqrt(5))/2,K))/sqrt(5);
fout<<fk;
fin.close();
fout.close();
}