Python验证6174猜想

num=int(input())
c=num
while c!=6174:
    digits=list(str(c))
    digits.sort(reverse=True)#排列最大数和最小数
   
if len(digits)<4:
        digits.append('0')
    a=int(''.join(digits))
    digits.reverse()
    b=int(''.join(digits))
    c=a-b
    print("%d-%d=%d" %(a,b,c))

 

猜你喜欢

转载自www.cnblogs.com/ggrm/p/10802677.html