login
a(n) = 1 if n is squarefree (A005117), otherwise a(n) = Max {m < n | same prime factors as n, ignoring multiplicity}.
16

%I #34 Mar 13 2021 12:43:49

%S 1,1,1,2,1,1,1,4,3,1,1,6,1,1,1,8,1,12,1,10,1,1,1,18,5,1,9,14,1,1,1,16,

%T 1,1,1,24,1,1,1,20,1,1,1,22,15,1,1,36,7,40,1,26,1,48,1,28,1,1,1,30,1,

%U 1,21,32,1,1,1,34,1,1,1,54,1,1,45,38,1,1,1,50,27,1,1,42,1,1,1,44,1,60,1,46,1,1,1,72,1,56,33,80,1,1,1,52,1,1,1,96

%N a(n) = 1 if n is squarefree (A005117), otherwise a(n) = Max {m < n | same prime factors as n, ignoring multiplicity}.

%H Antti Karttunen, <a href="/A285328/b285328.txt">Table of n, a(n) for n = 1..10000</a>

%F If A008683(n) <> 0, a(n) = 1, otherwise a(n) = the largest number k < n for which A007947(k) = A007947(n).

%F Other identities. For all n >= 1:

%F a(A065642(n)) = n.

%e From _Michael De Vlieger_, Dec 31 2018: (Start)

%e a(1) = 1 since 1 is squarefree.

%e a(2) = 1 since 2 is squarefree.

%e 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.

%e a(6) = 1 since 6 is squarefree.

%e 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).

%e 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.

%e 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.

%e (End)

%t 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 *)

%o (Scheme)

%o (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)))))))

%o (PARI)

%o A007947(n) = factorback(factorint(n)[, 1]); \\ From _Andrew Lelechenko_, May 09 2014

%o 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

%o 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.

%o (Python)

%o from operator import mul

%o from sympy import primefactors

%o from sympy.ntheory.factor_ import core

%o def a007947(n): return 1 if n<2 else reduce(mul, primefactors(n))

%o def a(n):

%o if core(n) == n: return 1

%o r = a007947(n)

%o k = n - r

%o while k>0:

%o if a007947(k) == r: return k

%o else: k -= r

%o print([a(n) for n in range(1, 121)]) # _Indranil Ghosh_ and _Antti Karttunen_, Apr 17 2017

%Y A left inverse of A065642.

%Y Cf. A005117, A007947, A008479, A008683, A284571, A285111, A285331, A285329.

%Y Cf. also A079277.

%K nonn

%O 1,4

%A _Antti Karttunen_, Apr 17 2017