Menu

Python Practice: sums
📰

Python Practice: sums

DEV Community: beginners·ananyaa sri·16 days ago
#JTwuBhX5
#devtobeginners#devto#dev#number#temp
Long article (413 words) — no AI summary yet.
Reading 0:00
15s threshold

1.What is a Perfect Number?

A perfect number is a positive integer that is equal to the sum of all its positive proper divisors (excluding the number itself).

Example 1: Number 6

Divisors of 6 (excluding 6 itself):

1, 2, 3

Sum of divisors:

1 + 2 + 3 = 6

CODE:

perfect number

`num =6

div = 1

total = 0

while div < num:

if num % div ==0:

print(div)

total+=div

div+=1

print('sum of divisor:',total)

if total==num:

print("perfect number")

else:

print("not perfect")

`

* **2.What is a Neon Number? *

A Neon Number is a number where the sum of the digits of its square is equal to the original number.**

Example: Number 9

Step 1: Find the square

9 × 9 = 81

Step 2: Find the sum of digits

8 + 1 = 9

Step 3: Compare the result

Sum of digits = Original number

9 = 9

CODE:

num =3

sqaure= num*num

temp=sqaure

total=0

while temp > 0:

digit=temp % 10

total +=digit

temp = temp//10

if total==num:

print("neon ")

else:

print("not neon")

3.Strong Numbers are the numbers whose sum of factorial…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.