OFFSET
1,3
COMMENTS
LINKS
Rémy Sigrist, Table of n, a(n) for n = 1..10000
FORMULA
EXAMPLE
The square array A068424(n, k) begins:
n\k| 1 2 3 4 5 6
---+---------------------------------------
1| 1 2 6 24 120 720
2| 2 6 24 120 720 5040
3| 3 12 60 360 2520 20160
4| 4 20 120 840 6720 60480
- so a(1) = a(2) = a(6) = a(24) = a(120) = a(720) = 1,
a(3) = a(12) = a(60) = a(360) = 3,
a(4) = a(20) = 4.
PROG
(PARI) a(n) = { fordiv (n, d, my (r=n); for (k=d, oo, if (r==1, return (d), r%k, break, r/=k))) }
(PARI) a(n) = { for (i=2, oo, if (n%i!, forstep (j=i-1, 2, -1, my (d=sqrtnint(n, j)); while (d-1 && n%(d-1)==0, d--); while (n%d==0, my (r=n); for
(k=d, oo, if (r==1, return (if (d==2, 1, d)), r%k, break, r/=k)); d++)); break)); return (n) }
(Python)
from sympy import divisors
def a(n):
if n%2 == 0: return n
divs = divisors(n)
for i, d in enumerate(divs[:len(divs)//2]):
p = lastj = d
for j in divs[i+1:]:
if p >= n or j - lastj > 1: break
p, lastj = p*j, j
if p == n: return d
return n
print([a(n) for n in range(1, 70)]) # Michael S. Branicky, Jun 29 2021
CROSSREFS
KEYWORD
nonn
AUTHOR
Rémy Sigrist, Jun 24 2021
STATUS
approved