Help:=proc(): print(`RecToSeq(C,n), FPP(C,n), PC(A,B), APP(C,n) `): end: #RecToSeq(C,n): inputs a C-finite sequence, in our notation, and a pos. integer n, #and outputs the list of length n with the first n terms of the sequence. #For example, RecToSeq([[-1,-1],[1,1]],10); should output [1,1,2,3,5,8,13,21,34,55]. RecToSeq:=proc(C,n) local L,r,i,j: L:=C[2]: r:=nops(C[1]): for i from r+1 to n do L:=[op(L),add(-C[1][j]*L[i-j],j=1..r)]: od: L: end: #FPP(C,n): the first pseudoprime <=n according to the C-finite sequence #C. Try: FPP([[0,-1,-1],[0,2,3]],100); FPP:=proc(C,n) local L,r,i,j,k: L:=C[2]: r:=nops(C[1]): for i from r+1 to n do k:=add(-C[1][j]*L[r-j+1],j=1..r): L:=[op(2..r,L),k]: if k mod i =0 and not isprime(i) then RETURN(i): fi: od: FAIL: end: PC:=proc(A,B): [[0,-A,-B],[0,2*A,3*B]]:end: #APP(C,n): the pseudoprimes <=n according to the C-finite sequence #C. Try: FPP([[0,-1,-1],[0,2,3]],100); APP:=proc(C,n) local L,r,i,j,k,Ps: L:=C[2]: r:=nops(C[1]): Ps:=[]: for i from r+1 to n do k:=add(-C[1][j]*L[r-j+1],j=1..r): L:=[op(2..r,L),k]: if k mod i =0 and not isprime(i) then Ps:=[op(Ps),i]: fi: od: Ps: end: