Saturday, February 9, 2013

GOOD QUESTION FOR ISC PRACTICAL



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, 26, 27, 28, 29, ……….
Removing every second number produces the sequence
1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29,,………….
Removing every third number from the above sequence produces
1, 3, 7, 9, 13, 15, 19, 21, 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.
Write a program to generate and print lucky numbers less than a given natural number N where n<=50.
SAMPLE
INPUT       : N = 10 OUTPUT  :  THE LUCKY NUMBERS LESS THAN 10 ARE :         1 3 7
INPUT      : N = 25 OUTPUT :  THE LUCKY NUMBERS LESS THAN 25 ARE:          1 3 7 13 19

No comments: