Story:
Lucy asked George what his Lucky Number was. After some contemplation, George replied that he had several Lucky Numbers. After some brief confusion, Lucy asked George what his first n
Lucky Numbers are. George then asked you, his buddy, to write him a program to do the work for him.
The Challenge:
You will write a program/function that will receive from standard input/function argument a string or integer n
. The program/function will then return/output the first n
Lucky Numbers. Lucky numbers are defined via a sieve as follows.
Start with the positive integers:
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, ...
Now remove every second number:
1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, ...
The second remaining number is 3, so remove every third number:
1, 3, 7, 9, 13, 15, 19, 21, 25, ...
Now the next remaining number is 7, so remove every seventh number:
1, 3, 7, 9, 13, 15, 21, 25, ...
Next, remove every ninth number and so on. The resulting sequence are the lucky numbers.
Winning:
As usual for codegolf, fewest bytes wins.
As usual, submissions using standard loopholes are disqualified.