我爲哥德巴赫猜想做了一個python代碼。 的事情是我的輸出看起來像這樣哥德巴赫Python輸出
Enter the lower limit: 8
Enter the Upper limit: 10
8 = 3 + 5
10 = 3 + 7
10 = 5 + 5
我希望我的輸出看起來像爲
8 = 3 + 5
10 = 3 + 7 = 5 + 5
什麼有什麼辦法把它格式化成這樣?
我只是張貼for循環:
for n in range (lo_limit, up_limit + 1): #lo_limit and up_limit is what you input
if (n % 2 == 0):
for a in range (1, n + 1):
if is_prime(a): #is_prime represent numbers that are prime
for b in range(1, n + 1):
if is_prime(b):
if (a + b == n):
if (a <= b):
print(n, "=", a, "+", b)
的main()
顯示您的代碼。 – tzaman
這是非常難以回答,沒有任何代碼的工作。請考慮添加一個[MCVE](http://stackoverflow.com/help/mcve),或者至少您現在的代碼。 –
是的,有一種方式,但不是沒有看到您的代碼,創建輸出 –