Help:=proc(): print(`BestNei2(f,a,b,a0,b0),FindLC(f,a,b,a0,b0`): print(`Pell1(K)`): end: #BestNei2(f,a,b,a0,b0): inputs an expression f in the #symbols a,b, and integers a0,b0 and outputs #[a0,b0] if f(a0,b0) is smaller than its neighbors #otherwise [a1,b1], where f(a1,b1) is the `smallest neighbor' #and the new record BestNei2:=proc(f,a,b,a0,b0) local champ,Neis,a1,b1,rec,i: Neis:={[a0+1,b0],[a0-1,b0],[a0,b0-1],[a0,b0+1]}: champ:=[a0,b0]: rec:=subs({a=a0,b=b0},f): for i from 1 to nops(Neis) do a1:=Neis[i][1]: b1:=Neis[i][2]: if a1>0 and b1>0 then if subs({a=a1,b=b1},f)champ do champ:=NewChamp: NewChamp:=BestNei2(f,a,b,op(NewChamp))[1]: od: champ,BestNei2(f,a,b,op(champ))[2]: end: #inputs an integer K and outputs all solutions [a,b] #of a^2-2*b^2=1 in 1<=a1 then S:=[op(S),[a,b]]: fi: b:=sqrt((a^2+1)/2): if type(b,integer) and b>1 then S:=[op(S),[a,b]]: fi: od: S: end: #Inputs K and and outputs all the triplets [a,b,c] #such that (a^3+b^3-c^3) =\pm 1 Wiles3:=proc(K) local a,b,c,S: end: