Skip to main content

Posts

Showing posts with the label sequence

LUCKY NUMBER

PROGRAM : LUCKY NUMBER QUESTION: Consider the sequence of natural numbers. 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 …………………………………. Removing every second number produces the sequences 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23 …………………………. Removing every third number produces the sequences 1, 3, 7, 9, 13, 15, 19, 21, 25 …………………………. 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 . Write a program to generate and print lucky numbers less than a given number N. SAMPLE INPUT :   N = 10 OUTPUT :   The Lucky numbers less than 10 are:     1     3     7 SAMPLE INPUT :   N = 25 OUTPUT :   The Lucky numbers less than 25 are:     1     3  ...