Zak Seidov on Sat, 09 Jan 2016 18:04:38 +0100


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

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


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