MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: How can I get the previous Fibonacci calculated


prevFib[x_] := Module[{m, n, x2},
  x2 = SetPrecision[x, 100];
  If[x > 10^15,
   N[x/GoldenRatio],
   m = (n /. FindRoot[Fibonacci[n] - x2 == 0, {n, 100},
        WorkingPrecision -> 100]) - 1;
   If[Abs[m - Round[m]] < 10^-10,
    Fibonacci[Round[m]],
    N[Fibonacci[m]]]]]

prevFib[13]

8

prevFib[Fibonacci[50]] == Fibonacci[49]

True

prevFib[Fibonacci[10000]] == Fibonacci[9999]

True

prevFib[Fibonacci[20000]] == Fibonacci[19999]

True

prevFib[234.34*^10]

1.4483008492365037*^12


Bob Hanlon

---- ratulloch at gmail.com wrote: 

=============
Greetings

How can I get a previous Fibonacci calculated number in a specific
range.  I can calculate the previous number of phi see below

phi1 =(1+sqrt(5))/2

13/phi1

I tested it with 13 and got 8.034441857 .....so that works

but how can I get only the previous numbers of Fibonacci in a
specified range from 20 to 20000 if I input a large number like
234.34e10

tia sal2



  • Prev by Date: Re: difference between HeavisidePi and UnitBox
  • Next by Date: String as a variable name
  • Previous by thread: matching misspelled names
  • Next by thread: String as a variable name