login
a(1) = 1; For n > 1, a(n) is the smallest number different from a(1), ..., a(n-1) such that lcm(a(1), ..., a(n)) is a perfect square.
0

%I #12 Sep 20 2024 06:29:26

%S 1,4,2,9,3,6,12,16,8,18,24,25,5,10,15,20,30,36,40,45,48,49,7,14,21,28,

%T 35,42,50,56,60,63,64,32,70,72,75,80,81,27,54,84,90,96,98,100,105,108,

%U 112,120,121,11,22,33,44,55,66,77,88,99,110,126,132,135,140

%N a(1) = 1; For n > 1, a(n) is the smallest number different from a(1), ..., a(n-1) such that lcm(a(1), ..., a(n)) is a perfect square.

%C This is a permutation of the positive integers.

%C The squares appear in increasing order. For prime p, p^2 is immediately followed by p, 2*p, ..., (p-1)*p.

%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>

%e For n = 4, a(4) is different from 1, 2, 4, and lcm(4, a(4)) is a perfect square. Therefore, a(4) = 9.

%o (PARI) seq(n)={my(b=1, a=vector(n), M=Map()); for(n=1, #a, my(k=1); while(!issquare(lcm(b,k)) || mapisdefined(M,k), k++); a[n]=k; b=lcm(b,k); mapput(M,k,1)); a} \\ _Andrew Howroyd_, Aug 30 2024

%o (Python)

%o from math import isqrt, lcm

%o from itertools import count, islice

%o def sqr(n): return isqrt(n)**2 == n

%o def agen(): # generator of terms

%o an, aset, L, m = 1, {1}, 1, 2

%o for n in count(2):

%o yield an

%o an = next(k for k in count(m) if k not in aset and sqr(lcm(k, L)))

%o aset.add(an)

%o L = lcm(L, an)

%o while m in aset: m += 1

%o print(list(islice(agen(), 65))) # _Michael S. Branicky_, Aug 30 2024

%K nonn,easy

%O 1,2

%A _Yifan Xie_, Aug 25 2024