g | x | w | all
Bytes Lang Time Link
068Python 3 sympy240916T084624ZDavid Ch
126Python 3 sympy240416T225257ZCursorCo
074Wolfram Language Mathematica240416T020143Zatt
00905AB1E240414T084259ZNeil
082JavaScript V8240414T074951Zl4m2

Python 3 (sympy), 68 bytes

from sympy import*;j=2;print(1)
while 1:print(j*prevprime(j+1));j+=1

Try it online!

1 is an edge case. j counts all positive integers >1, then j*prevprime(j+1)=j*p(n) will always be a prime p(n) multiplied by j where p(n+1)>j>=p(n). Thus, the prime factors of j will always be <=p(n), and so p(n) is never multiplied by a lone prime <p(n) or >p(n). Additionally, each composite j is multiplied by a unique prime. Thus, there are no cases where any number is multiplied by more than one lone prime. Similar idea works with nextprime(j-1).

Python 3 (sympy), 126 bytes

from sympy import*
s=[]
g=x=0
while 1:
 x+=1;g=nextprime(g)
 if all(f%x or~-isprime(f//x)*(x-f)for f in s):print(g*x);s+=[g*x]

Try it online!

Not the shortest, not the fastest, but it does (partially) answer the additional math problems.

First we'll make some definitions to facilitate the proof of why this algorithm works. For any \$i \in \mathbb{N}\$ let \$S_i\$ be the sequence \$i,2i,3i,5i,\dots\$ that is, all numbers which are a product of \$i\$ and a prime or 1. We are looking to generate a sequence \$A\$ such that for all \$i \in \mathbb{N}\$ we have that \$|A \cap S_i|=1\$.

We construct our desired sequence as follows. We begin with an empty sequence, we then count up through all \$i \in \mathbb{N}\$, and at each step if we already have an element from \$S_i\$ in the sequence we do nothing, if we don't then we add \$i \cdot p_i\$ to the sequence, where \$p_i\$ is the \$i^{th}\$ prime number. It should be clear why this method will construct a sequence with at least one element from each \$S_i\$, but we also need to show that it does not have more than one element from any \$S_i\$. To show this we demonstrate the following two properties of \$i \cdot p_i\$.

First, \$i \cdot p_i \not \in S_j\$ for all \$j<i\$. This must be the case since if \$i \cdot p_i \in S_j\$ for some \$j<i\$ that would imply that \$i \cdot p_i= q \cdot a \cdot p_i\$ where \$q\$ is prime (or 1) and \$a \cdot p_i = j\$ but this is a contradiction since \$p_i > i > j\$

Second there can exist no \$j,k\$ where \$j<i<k\$ such that \$i \cdot p_i \in S_k\$ and \$j \cdot p_j \in S_k\$. This must also be true, since if there exist some \$j,k\$ where \$j<i<k\$ such that \$i \cdot p_i \in S_k\$ and \$j \cdot p_j \in S_k\$ that would imply that \$i \cdot p_i= q \cdot a \cdot p_i\$ where \$q\$ is prime (or 1) and \$a \cdot p_i = k\$ and that \$j \cdot p_j= r \cdot b \cdot p_j\$ where \$r\$ is prime (or 1) and \$b \cdot p_j = k\$. This would mean that \$a \cdot p_i = b \cdot p_j\$, and further that \$p_i\$ is a factor of \$b \cdot p_j\$, but this cannot be the case, since \$p_i > p_j\$ and \$p_i > i>j \geq b\$.

With these two properties we have shown that our sequence will never have more than one element from any \$S_i\$ since that would require adding an element to the sequence which is in a common \$S_i\$ with an element already in the sequence, which would require one of the above properties to be false.

So what about the answers to the additional math problems? Well if we look back through the proof we'll note that there's nothing particularly special about adding \$i \cdot p_i \$. In fact we should be able to choose any prime in place of \$p_i\$ so long as it is greater than \$i\$ and greater than the last prime we chose. This means that since there are infinite primes, we have infinite choices for what number to add each time we add a number to the sequence. Specifically, we make a countably infinite number of choices each with a countably infinite number of valid options, meaning we can construct an uncountably infinite number of valid sequences in this way. Note that this method is not exhaustive, and there are valid sequences which cannot be constructed in this way as well.

As for the second question, since the natural density of the primes is 0, any valid sequence constructed using the method described here will also have a natural density of 0 since the sequence will be more sparse than the primes by the nature of the construction.

Wolfram Language (Mathematica), 74 bytes

f@n_:=f/;!Or@@CompositeQ/@NumeratorDenominator[i/n]=Print@n
f@i~Do~{i,∞}

Try it online!

Greedy algorithm. Outputs (certain products of distinct primes)*(all squares) indefinitely. Appears to be equivalent to l4m2's solution.

05AB1E, 11 9 bytes

∞ʒÓ2ôÆƶO_

Try it online! Outputs the infinite sequence (well on TIO it will time out after about 18000). Explanation: Port of @att's formula (numbers where the dot product of the prime factorisation exponents with the sequence of nonzero integers in order of absolute value is zero). Edit: Saved 2 bytes thanks to @KevinCruijssen.

∞           Infinite sequence of positive integers
 ʒ          Filtered where
  Ó         Exponents of prime factorisation
   2ô       Split into pairs
     Æ      Reduced by subtraction
      ƶ     Multiply each value by its index (1-indexed)
       O_   Has zero sum

JavaScript (V8), 82 bytes

for(i=0,g=x=>x%k?k<i&&g(x,g[-i%k++||i]=z+=!g[k]):z^g(x/k);k=2;z=1)g(++i)||print(i)

Try it online!

att's method but on \$\mathbb F_2^\infty\$ rather than \$\mathbb Z\$


cardinality: Map Z to P, still 2N