OFFSET
1,2
COMMENTS
Inspired by Recaman's sequence A005132.
Some nonsquarefree numbers will not appear in this sequence. However, I conjecture that all squarefree numbers will appear. First occurrence of 2 is at a(766) = 2.
LINKS
Joseph C. Y. Wong, Table of n, a(n) for n = 1..10000
EXAMPLE
a(1) = 1 is squarefree, so a(2) = a(1) + 2 = 3.
a(7) = 28 = 2*2*7 is not squarefree, so a(8) = 2*7 = 14.
MATHEMATICA
rad[n_]:=Product[Part[First/@FactorInteger[n], i], {i, Length[FactorInteger[n]]}]; a[1]=1; a[n_]:=If[SquareFreeQ[a[n-1]], a[n-1]+n, rad[a[n-1]]]; Array[a, 60] (* Stefano Spezia, Mar 26 2024 *)
PROG
(Python)
from numpy import prod
def primefact(a):
factors = []
d = 2
while a > 1:
while a % d == 0:
factors.append(d)
a /= d
d = d + 1
return factors
def squarefree(a):
return sorted(list(set(primefact(a)))) == sorted(primefact(a))
sequence = [1]
a = 1
for n in range(1, 1001):
if not squarefree(a):
a = prod(list(set(primefact(a))))
else:
a += n+1
sequence.append(a)
print(sequence)
(PARI) lista(nn) = my(v = vector(nn)); v[1] = 1; for (n=2, nn, if (issquarefree(v[n-1]), v[n] = v[n-1]+n, v[n] = factorback(factor(v[n-1])[, 1])); ); v; \\ Michel Marcus, Mar 26 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
Joseph C. Y. Wong, Mar 24 2024
STATUS
approved