程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Ancient paper scraps python

編輯:Python

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("")

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved