You are viewing a single comment's thread. Return to all comments →
TAKE A LOOK AT THIS
import math s="" sum=0 def getvalue(S): global sum sum=0 for i in S: sum+=int(i)
return sum
def primeFactors(n,s): while n % 2 == 0: s+="2" n = n / 2
for i in range(3,int(math.sqrt(n))+1,2): while n % i== 0: s+=str(i) n = n / i if n > 2: s+=str(int(n)) return s
n=int(input()) sum1=getvalue(str(n)) sum2=getvalue(primeFactors(n,s))
if(sum1==sum2): print("1") else: print("0")
Seems like cookies are disabled on this browser, please enable them to open this website
Identify Smith Numbers
You are viewing a single comment's thread. Return to all comments →
TAKE A LOOK AT THIS
import math s="" sum=0 def getvalue(S): global sum sum=0 for i in S: sum+=int(i)
def primeFactors(n,s): while n % 2 == 0: s+="2" n = n / 2
n=int(input()) sum1=getvalue(str(n)) sum2=getvalue(primeFactors(n,s))
if(sum1==sum2): print("1") else: print("0")