JuniorMath

Perfect Number

A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. A divisor of an integer x is an integer that can divide x evenly.

Given an integer num, return true if num is a perfect number, otherwise return false.

Example 1
Inputnum = 28
Outputtrue
28 is equal to the sum of its positive divisors excluding itself: 1 + 2 + 4 + 7 + 14.
Example 2
Inputnum = 7
Outputfalse
7 is not equal to the sum of its positive divisors excluding itself.

Constraints

  • 1 <= num <= 10^8

Asked at 8 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate