1
0
Fork 0
euler/p25.c
2010-07-13 09:43:26 +02:00

24 lines
465 B
C

/*
* http://projecteuler.net
*
* Projecteuler - Problem 25
* -----------------------
* 2010-07-13 Henrik Hautakoski
*
* Alot of math, binet's formula
*/
#include <math.h>
#include <stdio.h>
#define LOG10PHI 0.20898764024997876221 /* log10((1+sqrt(5))/2) */
#define MAGIC 0.65051499783199062676 /* |(log10(5) / 2) - 1| */
#define fibolen(n) ((int) ceil(((n) - MAGIC) / LOG10PHI))
int main() {
printf("%i\n", fibolen(1000));
return 0;
}