login
A360825
a(n) is the remainder after dividing n! by its least nondivisor.
3
1, 1, 2, 2, 4, 1, 6, 2, 5, 1, 10, 1, 12, 3, 8, 1, 16, 1, 18, 4, 11, 1, 22, 22, 6, 5, 14, 1, 28, 1, 30, 33, 20, 31, 18, 1, 36, 7, 20, 1, 40, 1, 42, 8, 23, 1, 46, 19, 11, 9, 26, 1, 52, 30, 27, 10, 29, 1, 58, 1, 60, 43, 53, 56, 33, 1, 66, 12, 35, 1, 70, 1, 72, 27, 23
OFFSET
0,3
COMMENTS
For every term besides a(3), the least nondivisor is the next prime after n.
LINKS
FORMULA
a(n) = 1 <=> n in { A040976 } \ { 3 }.
a(n) = n <=> n in { A006093 }.
a(n) = n! mod A151800(n) for n > 3.
a(n) = A213636(n!) = A213636(A000142(n)).
a(A000040(n)) = A275111(n) for n >= 3.
a(n) > n <=> n in { A360805 }.
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
KEYWORD
nonn
AUTHOR
STATUS
approved