Lucky Numbers in Java | ISC Computer Science 2024 Practical
Lucky numbers are a sequence of natural numbers that remain after removing second, third, fourth, fifth and so on numbers respectively from a sequence of consecutive natural numbers.
Consider the sequence of first 20 natural numbers:
Removing every second number produces the sequence: 1, 3, 5, 7, 9, 11, 13, 15, 17, 19
Next removing every third number produces the sequence: 1, 3, 7, 9, 13, 15, 19
Next removing every fourth number produces the sequence: 1, 3, 7, 13, 15, 19
Further deleting every fifth number we get the sequence: 1, 3, 7, 13, 19
Deletion of every sixth number is not possible and the five numbers that are lucky to escape deletion remain indefinitely.