OFFSET
1,2
COMMENTS
p = 2*n+1 is prime iff it divides a(n) (Wilson's theorem) for instance let n=5, p =11 : a(5) = 14399 = 11*1309, so 11 is prime.
FORMULA
a(n) = n^2*(a(n-1)-(-1)^(n-1))+(-1)^n.
EXAMPLE
a(5) = 14399 because 14399=(5!)^2+(-1)^5.
PROG
(PARI) a(n) = n!^2+(-1)^n; \\ Michel Marcus, Oct 02 2016
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Serge Boisse (serge.boisse(AT)aviation-civile.gouv.fr), Dec 02 2003
EXTENSIONS
Offset corrected and edited by Michel Marcus, Oct 02 2016
STATUS
approved