cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A354224 Lexicographically earliest sequence of distinct positive integers such that a(1) = 1 and for any n > 1, the greatest common divisor of n and a(n) is a prime number.

This page as a plain text file.
%I A354224 #12 Jun 07 2022 11:12:22
%S A354224 1,2,3,6,5,4,7,10,12,8,11,9,13,16,18,14,17,15,19,22,24,20,23,21,30,28,
%T A354224 33,26,29,25,31,34,27,32,40,38,37,36,42,35,41,39,43,46,48,44,47,45,56,
%U A354224 52,54,50,53,51,60,49,63,62,59,55,61,58,57,66,70,64,67
%N A354224 Lexicographically earliest sequence of distinct positive integers such that a(1) = 1 and for any n > 1, the greatest common divisor of n and a(n) is a prime number.
%C A354224 This sequence is a self-inverse permutation of the positive integers.
%H A354224 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F A354224 a(n) = n iff n = 1 or n is a prime number.
%e A354224 The first terms are:
%e A354224   n   a(n)  gcd(n, a(n))
%e A354224   --  ----  ------------
%e A354224    1     1             1
%e A354224    2     2             2
%e A354224    3     3             3
%e A354224    4     6             2
%e A354224    5     5             5
%e A354224    6     4             2
%e A354224    7     7             7
%e A354224    8    10             2
%e A354224    9    12             3
%e A354224   10     8             2
%e A354224   11    11            11
%e A354224   12     9             3
%e A354224   13    13            13
%e A354224   14    16             2
%o A354224 (PARI) s=0; for (n=1, 67, for (v=1, oo, if (!bittest(s,v) && (n==1 || isprime(gcd(n,v))), print1 (v", "); s+=2^v; break)))
%o A354224 (Python)
%o A354224 from math import gcd
%o A354224 from sympy import isprime
%o A354224 from itertools import count, islice
%o A354224 def agen(): # generator of terms
%o A354224     aset, mink = {1}, 2; yield 1
%o A354224     for n in count(2):
%o A354224         k = mink
%o A354224         while k in aset or not isprime(gcd(n, k)): k += 1
%o A354224         aset.add(k); yield k
%o A354224         while mink in aset: mink += 1
%o A354224 print(list(islice(agen(), 67))) # _Michael S. Branicky_, May 23 2022
%Y A354224 Cf. A238758.
%K A354224 nonn
%O A354224 1,2
%A A354224 _Rémy Sigrist_, May 20 2022