HP Forums
(35S) Formula for Fibonacci Numbers - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (35S) Formula for Fibonacci Numbers (/thread-1450.html)



(35S) Formula for Fibonacci Numbers - Gerald H - 05-29-2014 05:24 AM

The formula finds the exact Fibonacci number for positive integer N on stack level X for N from 0 to 59, for higher values the result is approximate:

IP(((1+√5)÷2)^REGX÷√5+.4)-IDIV(REGX,56)-2*IDIV(REGX,58)-2*IDIV(REGX,59)

Improvements or alternative approaches welcome.

NB In case REGX is unfamiliar, access to REGX when entering a programme is via "EQN" key, setting algebraic mode, "R↓" key, giving access to registers x, y, z & t, & then choosing the desired register, ie REGX is the content of stack level X.