def func(): for i in range(2,1000): # count表示被整除的次数 count = 0 for j in range(1,i+1): if i%j==0: count+=1 # count==2说明,该数字只能被1和它本身整除 if count==2: if i==j: print(i) func()
python之输出 用print加上字符串,就可以向屏幕上输出指定的文字.用代码实现如下: >>> print "i love baby!" i love baby! >>> print("Hello World!") Hello World! >>> python会依次输出你输入的字符串或者数字,但是要注意的一点时,python在输出的过程中,如果越到“逗号”会用空格代替.例如: >>> pr
1.原地交换两个数字 x, y =10, 20 print x, y y, x = x, y print x, y 10 20 20 10 2.链状比较操作符 n = 10 print 1 < n < 20 print 1 > n <= 9 True False 3.使用三元操作符来实现条件赋值 [表达式为真的返回值] if [表达式] else [表达式为假的返回值] y = 20 x = 9 if (y == 10) else 8 print(x) 8 # 找abc中最小的
Prime power triples The smallest number expressible as the sum of a prime square, prime cube, and prime fourth power is 28. In fact, there are exactly four numbers below fifty that can be expressed in such a way: 28 = 22 + 23 + 2433 = 32 + 23 + 2449
原题: Prime summations It is possible to write ten as the sum of primes in exactly five different ways: 7 + 35 + 55 + 3 + 23 + 3 + 2 + 22 + 2 + 2 + 2 + 2 What is the first value which can be written as the sum of primes in over five thousand different