wap to check wheather a given number is a perfect number or not
Answers
Answered by
0
Answer:
1.Input the number.
2.Find all divisors of the number except the number itself.
3.If the sum of all divisors of the number is equal to the number, then return true. Else, return false.
Answered by
0
Answer:
Method 1: Starting from 1 to (num - 1), find all the divisors of the number. If the sum of divisors of the number is equal to the number, return true.
Method 2: Starting from 1 to (num^1/2),find all the divisors of the number. If the sum of divisors of the number is equal to the number, return true.
The second method is much more efficient than the first method.
Similar questions