I saw this question when I was doing the question,The answer to a bit too complicated,記錄一下自己的做法.
remnants of ancient paper:
In a mathematician of books with this one old pieces of paper,The words on the paper are already blurred,Only traces of what was written,It can also be vaguely seen that it is a multiplication formula,這個
What is the original number in the formula??The page with the slip of paper,“素數”The two words were marked out prominently,難道說,Does this formula have anything to do with prime numbers??Some people made a deep
incoming research,It turns out that every number in this formula is a prime number,And this formula is unique.Please use the programming to find the formula.
for num1 in range(100, 1000):
for num2 in range(10, 100):
num21 = num2 // 10
num22 = num2 % 10
num3 = num1 * num22
num4 = num1 * num21
num5 = num3 + num4 * 10
if num3<1000 or num3 >=10000 or num4<1000 or num4 >=10000 or num5 < 10000 or num5 >= 100000:
continue
s = str( num1) + str( num2) + str( num3) + str( num4) + str( num5)
for i in range( 0, len(s)):
if s[i] not in ['2', '3', '5', '7']:
break
if i == len(s)-1:
print(" ", num1)
print("* ", num2)
print("---------")
print(" ", num3)
print( num4)
print("--------")
print(num5)
print("")