### Perfect Number

#### Description

Given a integer N. You have to find the given number is a perfect number or not(Perfect number is a number, sum of all its factors is equal to double of given number).

#### Input Format

First line contains a integer N.

#### Output Format

Print Yes if it is perfect number else No.

Example 1:

Input
`6`
Output
`Yes`
Example 2:

Input
`48`
Output
`No`
Example 3:

Input
`28`
Output
`Yes`

### Approach

Approach 1: Traversing upto n

Step-i) initialize temp variable to two times of the given number
Step-ii) initialize answer variable to 0
Step-iii) run a loop from i=1 to i<= given number
Step-iv) if remainder of number / i is zero add i to the answer variable
Step-v) check if both temp and answer variable holds the same value
Step-vi) if they are same return "Yes" else return "No"

Time Complexity: O(n)
Space Complexity: O(1)

Approach 2: Traversing upto square root of n

Step-i) initialize temp variable to two times of the given number
Step-ii) initialize answer variable to 0
Step-iii) run a loop from i=1 to i<= square root of given number
Step-iv) if remainder of number/i is zero add both i and quotient to the answer variable
Step-v) check if both temp and answer varible holds the same value
Step-vi) if they are same return "Yes" else return "No"

Time Complexity: O(sqrt(n))
Space Complexity: O(1)

Note :

Let us know if you can come up with a better approach, mail us at support@theinquisitive.in Your approach will be reviewed and posted with credits to you.