#57Medium
Perfect numbers
Time: 1 s · Memory: 256 MB
- Nested loops
Statement
You are given a natural number . Print all perfect numbers not exceeding . A perfect number equals the sum of its divisors other than itself: , .
Input format
A single integer ().
Output format
A single line with the perfect numbers in increasing order, separated by spaces.
Examples
Input
100
Output
6 28
Input
10000
Output
6 28 496 8128
Note
For each number find the sum of its divisors in an inner loop. It is enough to check divisors up to , not up to : if is a divisor, so is . Write the condition as . Add separately and do not add itself.
