%I #16 Jun 13 2022 02:25:26
%S 0,1,1,1,1,0,1,1,1,0,1,1,1,0,0,1,1,0,1,0,1,0,1,0,1,0,1,1,1,1,1,1,0,0,
%T 1,0,1,0,1,1,1,0,1,1,0,0,1,1,1,0,0,0,1,0,1,1,1,0,1,1,1,0,0,1,0,1,1,0,
%U 0,0,1,0,1,0,1,1,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,1,1,0,0,0,1,0,1,0,1,1,1,1,1
%N a(n) = A182665(n) mod 2, where A182665(n) is the greatest x < n such that n divides x*(x-1).
%H Antti Karttunen, <a href="/A354920/b354920.txt">Table of n, a(n) for n = 1..100000</a>
%H <a href="/index/Ch#char_fns">Index entries for characteristic functions</a>
%F a(n) = A000035(A182665(n)).
%F a(n) = A000035(n) XOR A354918(n), where XOR is bitwise-XOR, A003987.
%o (PARI) A354920(n) = forstep(x=n-1,0,-1,if(!((x*(x-1))%n),return(x%2)));
%o (Python 3.8+)
%o from itertools import combinations
%o from math import prod
%o from sympy import factorint
%o from sympy.ntheory.modular import crt
%o def A354920(n):
%o if n == 1:
%o return 0
%o plist = tuple(p**q for p, q in factorint(n).items())
%o 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
%Y Parity of A182665. Characteristic function of A354921.
%Y Cf. A000035, A003987, A354918.
%K nonn
%O 1
%A _Antti Karttunen_, Jun 12 2022
|