Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double exp_rap(double a, int n) {
- if (n==0) return 1;
- int aux=exp_rap(a,n/2);
- if (n%2==0) return aux*aux;
- return aux*aux*a;
- }
- int fib_log(int n) {
- const static double SQRT_5=sqrt(5);
- const static double FI=(1+SQRT_5)/2;
- const static double UMENYSFI=1-FI;
- return ceil(exp_rap(FI,n)-exp_rap(UMENYSFI,n))/SQRT_5;
- }
Advertisement
Add Comment
Please, Sign In to add comment