top of page
Subham Das

Magic Number

It is a composite number whose sum of the digits is 10. If we extract the digits from the number then the sum of these digits will be 10. Are confused with the statement 'math.log(i, 10) + 1' ? This is nothing but a algorithm which will give us the number of digits in a number.


# Special Magic Composite Number whose sum is 10


import math


def prime(n) :

for i in range(2,n) :

if n%i == 0 :

return True

else :

return False


for i in range(1,100) :

c = prime(i)

if c == True :

quo = i

s = 0

d = int(math.log(i, 10)) + 1

for j in range(0,d) :

rem = quo % 10

quo = quo // 10

s = s + rem

if s == 10 :

print(i)


24 views0 comments

Recent Posts

See All

Prime Number or Not

This program checks a number is mathematically prime or not. It is a optimize program to check a number is prime number or not. # Program...

コメント


logo12.PNG
bottom of page