#K39307. Finding the Next Perfect Number
Finding the Next Perfect Number
Finding the Next Perfect Number
A perfect number is a positive integer that is equal to the sum of its proper divisors (excluding itself). In other words, a number \( n \) is perfect if it satisfies the equation:
\(\sum_{d|n,\,d<n} d = n\)
Your task is to find the smallest perfect number greater than a given integer \( x \). If there is no such perfect number available in the predefined sequence, output -1
.
Note: For the purpose of this problem, the list of known perfect numbers is fixed as \(6, 28, 496, 8128,\) and \(33550336\). You should use this list to determine the answer.
inputFormat
The input consists of a single integer \( x \) provided via standard input.
outputFormat
Output a single integer: the smallest perfect number greater than \( x \). If there is no perfect number greater than \( x \) in the list, output -1
.
5
6