OFFSET
0,3
COMMENTS
For every term besides a(3), the least nondivisor is the next prime after n.
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..10000
FORMULA
EXAMPLE
a(5) = 5! mod 7 = 120 mod 7 = 1.
MATHEMATICA
a[n_] := Module[{f = n!, m = n + 1}, While[Divisible[f, m], m++]; Mod[f, m]]; Array[a, 100, 0] (* Amiram Eldar, Feb 22 2023 *)
PROG
(PARI) a(n) = my(k=1, r); while(!(r=(n! % (n+k))), k++); r; \\ Michel Marcus, Feb 22 2023
(Python)
from functools import reduce
from sympy import nextprime
def A360825(n):
if n == 3: return 2
m = nextprime(n)
return reduce(lambda i, j: i*j%m, range(2, n+1), 1)%m # Chai Wah Wu, Feb 22 2023
(Python)
from functools import reduce
from sympy import nextprime
def A360825(n):
if n == 3: return 2
m = nextprime(n)
return (m-1)*pow(reduce(lambda i, j:i*j%m, range(n+1, m), 1), -1, m)%m # Chai Wah Wu, Feb 23 2023
CROSSREFS
KEYWORD
nonn
AUTHOR
Sebastian F. Orellana, Feb 22 2023
STATUS
approved