|
|
A182665
|
|
Greatest x < n such that n divides x*(x-1).
|
|
7
|
|
|
0, 1, 1, 1, 1, 4, 1, 1, 1, 6, 1, 9, 1, 8, 10, 1, 1, 10, 1, 16, 15, 12, 1, 16, 1, 14, 1, 21, 1, 25, 1, 1, 22, 18, 21, 28, 1, 20, 27, 25, 1, 36, 1, 33, 36, 24, 1, 33, 1, 26, 34, 40, 1, 28, 45, 49, 39, 30, 1, 45, 1, 32, 36, 1, 40, 55, 1, 52, 46, 56, 1, 64, 1, 38, 51, 57, 56, 66, 1, 65, 1, 42, 1, 64, 51, 44, 58, 56, 1, 81, 78, 69, 63, 48, 76, 64, 1, 50, 55
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,6
|
|
COMMENTS
|
|
|
LINKS
|
|
|
FORMULA
|
|
|
EXAMPLE
|
a(6) = 4 because 6 divides 4*3=12 but does not divide 5*4=20.
|
|
MAPLE
|
A:= proc(n)
max(map(u -> u*modp(1/u, n/u),
map(t -> mul(s[1]^s[2], s = t),
combinat[powerset](ifactors(n)[2]))))
end proc;
seq(A(n), n=1..100);
|
|
MATHEMATICA
|
a[n_] := Module[{x}, Max[x /. {ToRules[Reduce[Mod[x*(x-1), n] == 0 && Mod[x*(x+1), n] != 0, x, Integers] /. C[_] -> 0]}]]; a[1] = 0; a[2] = 1; Table[a[n], {n, 1, 100}] (* Jean-François Alcover, Mar 04 2014 *)
|
|
PROG
|
(Python 3.8+)
from itertools import combinations
from math import prod
from sympy import factorint
from sympy.ntheory.modular import crt
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)))) # Chai Wah Wu, Jun 12 2022
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,easy
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|