6 de agosto de 2012

Project Euler 25

#!/usr/bin/env python
from math import log
phi = (1+5**0.5)/2
#i used the following facts to derive a formula:
#-nth fibo aprox=(Phi^n)/sqrt(5)
#-# of digits of n aprox=log(n)
#where log is base 10 logarithm.
print int(round(999*log(10,phi)+0.5*log(5,phi)))

I don't know how does the image got rotated 90 
degrees when i uploaded it, i'll fix it later
(maybe)because i have to go to sleep. :)

No hay comentarios.:

Publicar un comentario