Chinaunix首页 | 论坛 | 博客
  • 博客访问: 86649
  • 博文数量: 47
  • 博客积分: 1410
  • 博客等级: 上尉
  • 技术积分: 625
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-11 12:11
文章分类

全部博文(47)

文章存档

2008年(47)

我的朋友

分类:

2008-11-14 17:31:10

Problem 41

11 April 2003

We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is also prime.

What is the largest n-digit pandigital prime that exists?    

def fun41():
    #n<=9
    #最大只能到7,1到8和1到9组成的数都能被3整除
    aList = range(1, 8)
    aList.reverse()
    for i in permutation(aList, 7):
        i = int("".join(map(str, i)))
        if isPrime(i):
            return i

answer is 7652413
time:0.0
阅读(360) | 评论(0) | 转发(0) |
0

上一篇:Problem 39

下一篇:Problem 42

给主人留下些什么吧!~~