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 of digits is equal to the original number. Given a number, the task is to check if it is a Strong Number or not
Example: 145
Split the number into digits: 1, 4, 5
Find each digit's factorial:
- 1! = 1
- 4! = 4 × 3 × 2 × 1 = 24
- 5! = 5 × 4 × 3 × 2 × 1 = 120 Add them:
1 + 24 + 120 = 145
The answer is equal to the original number.
145 is a Strong Number
CODE:
`num = 145
temp = num
total = 0
while temp > 0:
digit = temp % 10
fact = 1
i = 1
while i <= digit:
fact = fact * i
i += 1
total += fact
temp = temp // 10
if total == num:
print("its strong")
else:
print("not strong")`
**4.[Sum of First n numbers --> Multiplication of first n numbers]
Automorphic Number
3 --> 3 power 2 --> 9
4 --> 4 power 2 --> 16
5 --> 5 power 2 --> 25
CODE:
`num = 25
square = num * num
temp = num
count = 0
while temp > 0:
count += 1
temp = temp // 10
last = square % (10 ** count)
if last == num:
print("Automorphic Number")
else:
print("Not an Automorphic Number")`
Top comments (0)