Practical Questions ISC 2001

Removing every third number from the above sequence produces the sequence

1, 3, 7, 9, 13, 15, 19, 25, 27………………………..

This process continues indefinitely by removing the fourth, fifth and so on, till after a fixed number of steps, certain natural numbers remain indefinitely. These are known as lucky numbers. Writes a program to generate and print lucky numbers less than a given natural N, where N <= 50.[2001]