Given a number n, check if the number is perfect or not. A number is said to…

PYQ Wipro NLTH / Elite 2025

Given a number n, check if the number is perfect or not. A number is said to be perfect if sum of all its factors excluding the number itself is equal to the number.

Input format: a single integer n on standard input.
Output format: print true if n is a perfect number, and false otherwise.

Examples:

Input: 6
Output: true
Explanation: Factors of 6 are 1, 2, 3 and 6. Excluding 6 their sum is 6 which is equal to n itself. So, it's a Perfect Number.

Input: 10
Output: false
Explanation: Factors of 10 are 1, 2, 5 and 10. Excluding 10 their sum is 8 which is not equal to n itself. So, it's not a Perfect Number.

Input: 15
Output: false
Explanation: Factors of 15 are 1, 3, 5, 15. Excluding 15 their sum is 9 which is not equal to n itself. So, it's not a Perfect Number.

Constraints:
1 ≤ n ≤ 109

Attempted by 4 students.

Sign up free to check your answer

Sign up free

Explore the full course: Wipro Preparation

Loading lesson…