Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: How can I get the previous Fibonacci calculated

  • To: mathgroup at smc.vnet.net
  • Subject: [mg100312] Re: How can I get the previous Fibonacci calculated
  • From: "David W. Cantrell" <DWCantrell at sigmaxi.net>
  • Date: Mon, 1 Jun 2009 07:04:39 -0400 (EDT)
  • References: <gvtmjh$giu$1@smc.vnet.net>

Bob Hanlon <hanlonr at cox.net> wrote:
> 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

But that's not a Fibonacci number! I suggest

In[7]:=
n = 234.34*^10;
inv = Round[Log[GoldenRatio, Sqrt[(Sqrt[5]*n + Sqrt[5*n^2 - 4])*
        (Sqrt[5]*n + Sqrt[5*n^2 + 4])]/2]];
Fibonacci[inv - 1]

Out[7]=
1548008755920

I am guessing that the OP actually wants to find the Fibonacci number which
immediately precedes a given _Fibonacci number_. If that guess is correct,
that is, if n is actually supposed to be a Fibonacci number, then my inv
will always work correctly for n >= 2.

But CAUTION:  If n is not a Fibonacci number, then my method may give an
incorrect answer. In the example, 234.34*^10 is not a Fibonacci number and
so there was no guarantee that my method would give the correct result,
although it happened to do so.

David W. Cantrell


> ---- 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: MatrixForm affects values instead of only printing
  • Next by Date: Re: Indexed Slot in a Rule - How to do it??
  • Previous by thread: Re: The standard deviation of Three fitting parameters is bigger than
  • Next by thread: Re: Re: How can I get the previous Fibonacci calculated