Demo entry 6623405

What?

   

Submitted by anonymous on Jun 07, 2017 at 16:35
Language: Python 3. Code size: 542 Bytes.

# 1. Prompt for a number num
num_str = input("Enter your number")
num = int(num_str)


# 2. Compute the sum of divisors of num and store it in sum_of_divisors: 
divisor = 1
sum_of_divisors = 0
while divisor < num:
    if num % divisor == 0:        # divisor evenly divides num
        sum_of_divisors = sum_of_divisors + divisor
    divisor = divisor + 1

# 3. Compare sum_of_divisors and num and respond accordingly:

if number == sum_of_divisors:
    print(number,"is perfect")
else:
    print(number,"is not perfect")

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).