Cod sursa(job #1701386)
Utilizator | Data | 12 mai 2016 22:23:53 | |
---|---|---|---|
Problema | Al k-lea termen Fibonacci | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.25 kb |
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int k;
float x,y,z,t,u,v,w;
cout<<"k=";
cin>>k;
x=sqrt(5);
y=(1+x)/2;
z=(1-x)/2;
t=pow(y,k);
u=pow(z,k);
v=t-u;
w=v/x;
cout<<w;
}