John Cremona on Sat, 09 Jan 2016 18:13:26 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Re[2]: fibonacci(n) for large n's


On 9 January 2016 at 17:04, Zak Seidov <zakseidov@yahoo.com> wrote:
> Great,
> Bill's code is much more faster than standard fibonacci(n).
> Then my Q is:
> why not to  implement this code in PARI's fibonacci(n)?
> One related however silly Q:
> How to retrieve 5 in result of, say, Mod(12,7)?
> PARI gives as  a result Mod(5,7) but how to retrieve 5?

lift()

e.g. lift(Mod(5,7))  -->  5

Johhn

> (sorry my math and PARI level is so low:()
> Thx,Zak
>
>
> Пятница, 8 января 2016, 19:35 +01:00 от Bill Allombert
> <Bill.Allombert@math.u-bordeaux.fr>:
>
> One simpler and faster way is
> myfibo(n)=polcoeff(lift(Mod(x,x^2-x-1)^n),1)
>
> which you can restrict mod m:
> myfibomod(n,m)=polcoeff(lift(Mod(x*Mod(1,m),x^2-x-1)^n),1)
>
> Cheers,
> Billl.
>
>