Given a number \$n\$, you are to compute the sequence of positive numbers where for each number \$a\$, the \$n\$-times multiple \$n\cdot a\$ is missing.
Example
We always start with the sequence of all positive numbers: $$1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, \dots$$
For \$n=2\$, going left-to-right, we first encounter \$1\$ and remove its double, \$2\$: $$\require{cancel}\underline{1},\!\cancel{2}\!,3,4,5,6,7,8,9,10,11,12,13,14,15, \dots$$
Next is in line is thus number \$3\$, so we remove \$6\$: $$1,\!\cancel{2}\!,\underline{3},4,5,\!\cancel{6}\!,7,8,9,10,11,12,13,14,15, \dots$$ Continuing, we remove the \$8\$ because of the \$4\$, then the \$10\$ because of the \$5\$, but not the \$12\$ (because the \$6\$ has already been removed), then the \$14\$ and so on: $$1,\!\cancel{2}\!,3,4,5,\!\cancel{6}\!,\underline{7},\!\cancel{8}\!,9,\!\cancel{10}\!,11,12,13,\!\cancel{14}\!,15, \dots$$
Likewise, for \$n=3\$, we get the following sequence by removing the triple of each number we encounter: $$1,2,\!\cancel{3}\!,4,5,\!\cancel{6}\!,7,8,9,10,11,\!\cancel{12}\!,13,14,\!\cancel{15}\!, \dots$$
Task
Given a number \$n>1\$ as input, compute the respective sequence as described above. The default rules for sequence challenges apply, meaning you can either choose to
- take no further input and output the sequence indefinitely, or
- take an index \$i\$ as additional input and output (zero or one indexed)
- the element at this index, or
- all elements of the sequence up to this index.
This is code-golf, so the shortest answer in bytes in each language wins.
Testcases
n=2: [1,3,4,5,7,9,11,12,13,15,16,17,19,20,21,23,25,27,28,29,31,33,35,36,37,39,41,43,44,45,47,48,49,51,52,53,55,57,59,60,61,63,64,65,67,68,69,71,73,75,76,77,79,80,81,83,84,85,87,89,91,92,93,95,97,99,100,101,103,105,107,108,109,111,112,113,115,116,117,119,121,123,124,125,127,129,131,132,133,135,137,139,140,141,143,144,145,147,148,149]
n=3: [1,2,4,5,7,8,9,10,11,13,14,16,17,18,19,20,22,23,25,26,28,29,31,32,34,35,36,37,38,40,41,43,44,45,46,47,49,50,52,53,55,56,58,59,61,62,63,64,65,67,68,70,71,72,73,74,76,77,79,80,81,82,83,85,86,88,89,90,91,92,94,95,97,98,99,100,101,103,104,106,107,109,110,112,113,115,116,117,118,119,121,122,124,125,126,127,128,130,131,133]
n=4: [1,2,3,5,6,7,9,10,11,13,14,15,16,17,18,19,21,22,23,25,26,27,29,30,31,32,33,34,35,37,38,39,41,42,43,45,46,47,48,49,50,51,53,54,55,57,58,59,61,62,63,65,66,67,69,70,71,73,74,75,77,78,79,80,81,82,83,85,86,87,89,90,91,93,94,95,96,97,98,99,101,102,103,105,106,107,109,110,111,112,113,114,115,117,118,119,121,122,123,125]
n=5: [1,2,3,4,6,7,8,9,11,12,13,14,16,17,18,19,21,22,23,24,25,26,27,28,29,31,32,33,34,36,37,38,39,41,42,43,44,46,47,48,49,50,51,52,53,54,56,57,58,59,61,62,63,64,66,67,68,69,71,72,73,74,75,76,77,78,79,81,82,83,84,86,87,88,89,91,92,93,94,96,97,98,99,100,101,102,103,104,106,107,108,109,111,112,113,114,116,117,118,119]
n=6: [1,2,3,4,5,7,8,9,10,11,13,14,15,16,17,19,20,21,22,23,25,26,27,28,29,31,32,33,34,35,36,37,38,39,40,41,43,44,45,46,47,49,50,51,52,53,55,56,57,58,59,61,62,63,64,65,67,68,69,70,71,72,73,74,75,76,77,79,80,81,82,83,85,86,87,88,89,91,92,93,94,95,97,98,99,100,101,103,104,105,106,107,108,109,110,111,112,113,115,116]
n=17: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,103,104,105,106]
For n=2, the sequence is A003159, for n=3 A007417, and A171948 for n=4 when dropping the zero.
1 3 4 5 7 9 ...
not. \$\endgroup\$n=6
test case, after having almost posted a wrong solution that fails for numbers with more than one distinct prime factor. \$\endgroup\$