码迷,mamicode.com
首页 > 其他好文 > 详细

计算大于正整数1600000的最小双基回文数

时间:2016-03-19 12:35:24      阅读:258      评论:0      收藏:0      [点我收藏+]

标签:

def judge(n):
    count=0
    for i in xrange(2,10+1):
        x=‘‘
        tmp=n
        while tmp!=0:
            x+=str(tmp%i)
            tmp/=i
        if x==x[::-1]:
            count+=1
        if count==2:
            return True
    return False

def foo():
    n=1600000
    while True:
        n+=1
        if judge(n):
            print n
            break
    pass

if __name__ == __main__:
    foo()
    print ok
    pass

 

计算大于正整数1600000的最小双基回文数

标签:

原文地址:http://www.cnblogs.com/test404/p/5294714.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!