Featured image of post Solve the Problem in a April Fool's Joke

Solve the Problem in a April Fool's Joke

On April 1st, one of the post on v2ex (An online community of developers and designers in China1) become viral. The post title is “Seeking Dates” and it is posted on April 1st, so most reactions of this post are pointing out that this is the “new trap” of the recruiters.

Here is the translation:

I am born and raised in Hangzhou. I am a science student at Zhejiang University … I hope to find a man can pass the following test. My Wechat ID is my Family name Lin followed with two prime number. The smaller prime number is in the front. The product of these two prime numbers 7140229933. If you can find my Wechat ID, I will sincerely date you. Bula bula bula …

Disregard if it is a joke, I think the question is interesting. So let’s solve it.

The idea is using Exhaustive Method (Brute Force Method) to find two prime factors. However, 7,140,229,933 is a relatively large number. To find all prime number could take a long time. Since 7,140,229,933 is the product of two prime, one of the numbers must smaller than the Square Root of it. Therefore the order of magnitude of range could reduce from $10^9$ to $10^4$. Here is my solution.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
import time
start = time.time()

# The input number
input = 7140229933

for x in range (2,int(input**(0.5))):
  if input%x ==0:
    print(x)
    break

print(int(input / 83777))

end = time.time()
print('Total Time: {}s.'.format(end - start))

Output:

1
2
3
83777
85229
Total Time: 0.01737499237060547s.

So the two prime number are 83777 and 85229.


  1. https://zh.wikipedia.org/wiki/V2EX ↩︎

comments powered by Disqus
All contents licensed under CC BY-NC-SA 4.0 本站所有内容基于CC BY-NC-SA 4.0协议发布,转载需要署名
Built with Hugo
Theme Stack designed by Jimmy