This is my first challenge!
Background
Perfect number is a positive integer, that is equal to the sum of all its divisors, except itself.
So 6
is perfect number, since 1 + 2 + 3 = 6
.
On the other hand 12
is not, because 1 + 2 + 3 + 4 + 6 = 16 != 12
.
Task
Your task is simple, write a program, which will, for given n
, print one of these messages:
I am a perfect number, because
d1 + d2 + ... + dm = s == n
I am not a perfect number, becaused1 + d2 + ... + dm = s [<>] n
Where
d1, ... dm
are all divisors of n
except for n
.
s
is the sum of all divisors d1, ..., dm
(again, without n
).
[<>]
is either <
(if s < n
) or >
(if s > n
).
Examples
For n
being 6
: "I am a perfect number, because 1 + 2 + 3 = 6 == 6"
For n
being 12
: "I am not a perfect number, because 1 + 2 + 3 + 4 + 6 = 16 > 12"
For n
being 13
: "I am not a perfect number, because 1 = 1 < 13"
Rules
n
is not bigger than your language's standardint
.- You can read
n
from standard input, from command line arguments or from a file. - Output message has to be printed on standard output and no additional characters can appear in the output (it may have trailing whitespace or newline)
- You may not use any built-ins or library functions which would solve the task (or its main part) for you. No
GetDivisors()
or something like that. - All other standard loopholes apply.
Winner
This is code-golf so shortest code in bytes wins!
=
and==
in the same equation? That makes no sense. It should bed1 + d2 + ... + dm = s = n
IMO. \$\endgroup\$