我对编程完全陌生,今晚我需要一些帮助。我有一个问题需要解决,我需要在给定的数字范围内证明哥德巴赫猜想。我需要确保这个数字是偶数,找出哪些素数加起来,打印出来并找出该范围内的哪个数字具有最多的对数。我的问题如下:
for i in range (lower, upper + 1 ):
if ( pairs > max_pairs):
max_pairs = pairs
# Check if Number is Even
if ( i % 2 == 0 ):
prime1 = 0
prime2 = 0
pairs = 0
print ( i, "=")
# Find Prime Numbers less than the Current Even Number
for x in range ( 2 , ( i - 1 ) ):
prime = is_prime ( x )
if ( prime == False ):
break
prime1 = x
for n in range ( 2, ( i - 1 ) ):
prime = is_prime (n)
if ( prime == False ):
break
prime2 = n
if ( ( prime1 + prime2) == i ):
prime_sum = True
else:
break
if ( prime1 >= prime2 ):
prime3 = prime1
prime1 = prime2
prime2 = prime3
if ( prime_sum == True ):
print ( prime1, "+", prime2 )
pairs += 1
如果不满足这两个 if 条件之一,我需要使用 n 重复 for 循环,但是 break 将我送回 x 循环。如果这两个条件之一为假而不结束我的程序,我怎样才能让它重复?