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)
コメント