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

全部博文(47)

文章存档

2008年(47)

我的朋友

分类:

2008-11-15 20:54:02

Problem 46

20 June 2003

It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a prime and twice a square.

9 = 7 + 212
15 = 7 + 222
21 = 3 + 232
25 = 7 + 232
27 = 19 + 222
33 = 31 + 212

It turns out that the conjecture was false.

What is the smallest odd composite that cannot be written as the sum of a prime and twice a square?    

def fun46():
    i = 35
    while 1:
        if isPrime(i):           
            i += 2
        else:
            isOk = False
            for s in range(1, int(math.sqrt(i/2)+2)):
                t = i - 2*(s**2)
                if t <= 0:
                    isOk = True
                    break
                else:
                    if isPrime(t):
                        i += 2
                        break
            if isOk:
                break
    return i

answer is 5777
time:0.125
阅读(396) | 评论(0) | 转发(0) |
0

上一篇:Problem 44

下一篇:Problem 47

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