OFFSET
1,4
LINKS
Antti Karttunen, Table of n, a(n) for n = 1..10000
FORMULA
EXAMPLE
From Michael De Vlieger, Dec 31 2018: (Start)
a(1) = 1 since 1 is squarefree.
a(2) = 1 since 2 is squarefree.
a(4) = 2 since 4 is not squarefree and 2 is the largest number less than 4 that has all the distinct prime divisors that 4 has.
a(6) = 1 since 6 is squarefree.
a(12) = 6 since 12 is not squarefree and 6 is the largest number less than 12 that has all the distinct prime divisors that 12 has. (6 is also the squarefree root of 12).
a(16) = 8 since 16 is not squarefree and 8 is the largest number less than 16 that has all the distinct prime divisors that 16 has.
a(18) = 12 since 18 is not squarefree and 12 is the largest number less than 18 that has all the distinct prime divisors that 18 has.
(End)
MATHEMATICA
Table[With[{r = DivisorSum[n, EulerPhi[#] Abs@ MoebiusMu[#] &]}, If[MoebiusMu@ n != 0, 1, SelectFirst[Range[n - 2, 2, -1], DivisorSum[#, EulerPhi[#] Abs@ MoebiusMu[#] &] == r &]]], {n, 108}] (* Michael De Vlieger, Dec 31 2018 *)
PROG
(Scheme)
(definec (A285328 n) (if (not (zero? (A008683 n))) 1 (let ((k (A007947 n))) (let loop ((n (- n k))) (if (= (A007947 n) k) n (loop (- n k)))))))
(PARI)
A007947(n) = factorback(factorint(n)[, 1]); \\ From Andrew Lelechenko, May 09 2014
A285328(n) = { my(r=A007947(n)); if(core(n)==n, 1, n = n-r; while(A007947(n) <> r, n = n-r); n); }; \\ After Python-code below - Antti Karttunen, Apr 17 2017
A285328(n) = { my(r); if((n > 1 && !bitand(n, (n-1))), (n/2), r=A007947(n); if(r==n, 1, n = n-r; while(A007947(n) <> r, n = n-r); n)); }; \\ Version optimized for powers of 2.
(Python)
from operator import mul
from sympy import primefactors
from sympy.ntheory.factor_ import core
def a007947(n): return 1 if n<2 else reduce(mul, primefactors(n))
def a(n):
if core(n) == n: return 1
r = a007947(n)
k = n - r
while k>0:
if a007947(k) == r: return k
else: k -= r
print([a(n) for n in range(1, 121)]) # Indranil Ghosh and Antti Karttunen, Apr 17 2017
CROSSREFS
KEYWORD
nonn
AUTHOR
Antti Karttunen, Apr 17 2017
STATUS
approved