problem 25
This commit is contained in:
parent
b51b2ba5fc
commit
296a8b84c3
1 changed files with 24 additions and 0 deletions
24
p25.c
Normal file
24
p25.c
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue