Bill Allombert on Fri, 08 Jan 2016 19:35:35 +0100


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

Re: fibonacci(n) for large n's


On Fri, Jan 08, 2016 at 06:25:00PM +0000, mike_liz.day@tiscali.co.uk wrote:
> Whether or not you're working modulo something,  consider
> the 2x2 
> matrix M = [0 1] [1 1] , ie with all Mij = 1 except for M11 = 0 .

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.