`
to_zoe_yang
  • 浏览: 143257 次
  • 性别: Icon_minigender_2
  • 来自: 01
社区版块
存档分类
最新评论

Problem 46

 
阅读更多

问题描述:

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 + 2×12
15 = 7 + 2×22
21 = 3 + 2×32
25 = 7 + 2×32
27 = 19 + 2×22
33 = 31 + 2×12

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?

 

解决问题: 

		int i =33;
		boolean ok = true;
		for(;ok;){
			i=i+2;
			int j;
			if(IsPrime(i)){
			for( j=1; 2*j*j<i; j++){
				if(IsPrime(i-2*j*j)){
					break;
				}
			}
			if(2*j*j>=i){
				System.out.println("j:"+j+".i:"+i);
				ok = false;
			}
			}
		}
		 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics