A problem by Shakil Ahmed

Level pending

Which one is a perfect number?

28 21 29 25

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

Mehul Arora
Jan 8, 2015

A perfect number is one which is half the sum of all it's factors.

Hence the answer is 28.

Brock Brown
Jan 8, 2015
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
def divisors(x):
    answers = []
    n = 1
    while n < x:
        if x % n == 0:
            answers.append(n)
        n += 1
    return answers
def perfect(x):
    return x == sum(divisors(x))
for i in (29, 25, 21, 28):
    if perfect(i):
        print "Answer:", i

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...