login
Indices of nonprime terms in A354790.
5

%I #17 Jul 18 2022 09:49:02

%S 1,7,14,15,17,29,31,35,59,63,64,71,79,119,120,127,129,143,159,223,239,

%T 241,255,259,260,287,288,319,320,447,479,483,484,511,512,519,521,575,

%U 577,639,641,895,959,960,967,968,969,1023,1025,1039,1043,1044,1151,1152

%N Indices of nonprime terms in A354790.

%H Rémy Sigrist, <a href="/A354791/b354791.txt">Table of n, a(n) for n = 1..5715</a>

%H Rémy Sigrist, <a href="/A354791/a354791.txt">C program</a>

%o (Python)

%o from math import lcm, gcd

%o from itertools import count, islice

%o from collections import deque

%o from sympy import factorint

%o def A354791_gen(): # generator of terms

%o aset, aqueue, c, b, f, i = {1}, deque([1]), 2, 1, True, 1

%o yield 1

%o while True:

%o for m in count(c):

%o if m not in aset and gcd(m,b) == 1 and all(map(lambda n:n<=1,fs:=factorint(m).values())):

%o i += 1

%o if len(fs) > 1:

%o yield i

%o aset.add(m)

%o aqueue.append(m)

%o if f: aqueue.popleft()

%o b = lcm(*aqueue)

%o f = not f

%o while c in aset:

%o c += 1

%o break

%o A354791_list = list(islice(A354791_gen(),30)) # _Chai Wah Wu_, Jul 17 2022

%o (C) See Links section.

%Y Cf. A354790, A354792.

%K nonn

%O 1,2

%A _Michael De Vlieger_ and _N. J. A. Sloane_, Jul 17 2022

%E More terms from _Rémy Sigrist_, Jul 17 2022