Saturday, July 21, 2012

Perfect Number Generate

Assalamu Alaikum. Hope, you all are well by the grace of Almighty ALLAH. Today we learn how to find out the perfect numbers between two limits. Take a look at the Problem.

Problem: Write a program that prints the list of all perfect numbers between X and Y., where Y>X. User will input the value of X and Y. If X is not lower than Y, a message will be given "Invalid range".




Solution:

A perfect number is one whose sum of factors is equal to the number like 6. 6 has three factors 1, 2, 3. When we add 1+ 2+ 3, it is equal to 6. Hence 6 is a perfect number. Likewise 28 is another perfect number.

Now, take a look at the program.




Thank You all.

0 comments:

Post a Comment