OFFSET
1
LINKS
FORMULA
PROG
(PARI) A354920(n) = forstep(x=n-1, 0, -1, if(!((x*(x-1))%n), return(x%2)));
(Python 3.8+)
from itertools import combinations
from math import prod
from sympy import factorint
from sympy.ntheory.modular import crt
def A354920(n):
if n == 1:
return 0
plist = tuple(p**q for p, q in factorint(n).items())
return 1 if len(plist) == 1 else (n-int(min(min(crt((m, n//m), (0, -1))[0], crt((n//m, m), (0, -1))[0]) for m in (prod(d) for l in range(1, len(plist)//2+1) for d in combinations(plist, l))))) & 1 # Chai Wah Wu, Jun 12 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
Antti Karttunen, Jun 12 2022
STATUS
approved