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.
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.