[Answer and Winners] Mathematics × Programming Competition #6 [答案及得獎名單] 數學 × 程式編寫比賽 (第六回)

in #contest4 years ago (edited)

Mathematics × Programming Competition #6
Announcement of Answer and Winners

Designed by @nicolemoker

For Chinese version please scroll to the bottom. 中文版請見文末。


Given that x is a square number and p is a prime number, and they satisfy the equation x = 1000000007p + 1. Find the sum of all possible values of p.

Answer: 1000000009

Mathematical approach

Since x is a square number, we let x = n2, where n is a positive integer. Now we have

n2 = 1000000007p + 1

( n + 1 ) ( n - 1 ) = 1000000007p

It is easy to check that 1000000007 is a prime number either by writing a program or using some online tools. Therefore there are only two possibilities:

We have p = 1000000005 or 1000000009, but only 1000000009 is a prime, so our answer is 1000000009.

Programming approach

It is not quite possible to solve this problem directly by brute force programming, as the question gives a very large number 1000000007, and also asked for the sum of possible values (though there is actually only one possible value :p). However even if you are not able to think of the mathematical solution as shown above, you may still have a chance to find out the answer. Let me show you how:-

  1. You may think that there must be something special with the number 1000000007. Just use some online tools to analyze this number and you will find that it is a prime.
  2. However the number is too large! Let's try to replace the number by some smaller primes, such as 23, 29, 31, ...
  3. Write a program to search for possible values of p that fits our equation. There is no upper bound for the value of p so you can let the program run for several minutes for each case and then stops it.
  4. You should observe that the number of possible values of p in each case is either p - 2 or p + 2. Now we have found out the key without the use of mathematical skills!


Among 24 participants, there are 15 people who got the correct answers. Thank you for your participation!

@carobetc @tvb @aaronli @kitcat @philipheihei @kona @etzel @rayccy @thomaskikansha @doughtaker @armandocat @tensaix2j @victory622 @ghasemkiani @susankiani @ariak @marziehshahabi @superbing @justyy @dailyfortune @ideamaker @challk @megii @kevingau

SBD payout of the the question post = 45.638 SBD

Besides, @steemstem has generously sponsored 7.5 SP, 5 SP and 2.5 SP for the first, second and third prizes!

The winners and prizes are tabulated below:

@tvbFirst prize45.638 / 8 = 5.704 SBD + 7.5 SP
@kitcatSecond prize45.638 / 8 = 5.704 SBD + 5 SP
@etzelThird prize45.638 / 8 = 5.704 SBD + 2.5 SP
@rayccyConsolation prize45.638 / 8 = 5.704 SBD
@ideamakerConsolation prize45.638 / 8 = 5.704 SBD
@marziehshahabiConsolation prize45.638 / 8 = 5.704 SBD
@ghasemkianiConsolation prize45.638 / 8 = 5.704 SBD
@thomaskikanshaConsolation prize45.638 / 8 = 5.704 SBD

Congratulations to the winners!

The steemSTEM project (@steemstem) is a community-supported project aiming to increase the quality and the visibility of STEM (STEM is the acronym for Science, Technology, Engineering and Mathematics) articles on Steemit. Please support steemSTEM by following @steemstem and joining the chat channel. You can also consider joining a private curation trail to further support steemSTEM by asking about it in the chat channel. In order to further promote the use of the chat channel, I will stop announcing the time of next competition via a post. Instead I will announce the time in advance in the chat channel!

數學 × 程式編寫比賽 (第六回)

Designed by @nicolemoker


已知 x 為平方數,而 p 為質數,且符合公式 x = 1000000007p + 1。求 p 所有可能值之和。

答案: 1000000009


由於 x 是一個平方數,我們設 x = n 2 ,其中n為正整數。現在我們有

n 2 = 1000000007 p + 1

n + 1)(n - 1)= 1000000007 p


因此可得p = 1000000005或1000000009,但只有1000000009是質數,所以答案是1000000009。


由於此問題包含非常大的數字1000000007,並且要求找出可能值的總和(儘管實際上只有一個可能值 :p),故並不太可能通過編程來暴力解決這個問題。然而,即使你不能想到數學解決的方法,你仍然有機會找出答案的 :)

  1. 你可能會覺得1000000007這個數字必定有其獨特之處。只需使用一些在線工具來分析這個數字,你會發現它是一個質數。
  2. 但是數值太大了!我們試著用一些較小的質數來代替這個數字,比如23、29、31...
  3. 編寫一個程序來搜索符合我們公式的 p 的可能值。 p 的值沒有上限,所以你可以讓程序為每個情況運行幾分鐘,待程序似乎沒有再找到新的可能值便終止。
  4. 你應該注意到,每種情況下 p 的可能值的數量只可能是 p - 2 或 p + 2。現在我們在沒有使用任何數學技能下已發現了題目的關鍵!



@carobetc @tvb @aaronli @kitcat @philipheihei @kona @etzel @rayccy @thomaskikansha @doughtaker @armandocat @tensaix2j @victory622 @ghasemkiani @susankiani @ariak @marziehshahabi @superbing @justyy @dailyfortune @ideamaker @challk @megii @kevingau

比賽題目帖文的SBD收入 = 45.638 SBD

另外,@steemstem 慷慨贊助了7.5 SP、5 SP以及2.5 SP予是次比賽的第一、二及三等獎!


@tvb一等獎45.638 / 8 = 5.704 SBD + 7.5 SP
@kitcat二等獎45.638 / 8 = 5.704 SBD + 5 SP
@etzel三等獎45.638 / 8 = 5.704 SBD + 2.5 SP
@rayccy安慰獎45.638 / 8 = 5.704 SBD
@ideamaker安慰獎45.638 / 8 = 5.704 SBD
@marziehshahabi安慰獎45.638 / 8 = 5.704 SBD
@ghasemkiani安慰獎45.638 / 8 = 5.704 SBD
@thomaskikansha安慰獎45.638 / 8 = 5.704 SBD


steemSTEM(@steemstem)是一個由steemit社群支持的項目,旨在宣傳STEM(STEM是科學,技術,工程和數學的首字母縮略詞)。 請追蹤 @steemSTEM 以及加入聊天頻道來支持steemSTEM。你還可以透過加入自動點讚系統來在為了進一步支持steemSTEM,詳情請在聊天頻道內向負責人士查詢。為了推廣聊天頻道的使用,我將不再透過發文來宣布下一場比賽的時間,我會在聊天頻道中提前公佈比賽時間。


I think there are some typos in the table of the winners.. I was so happy to be a winner 😹 but I guess that table is not updated to reflect the winners as shown in the image

oh thanks so much for reminding me!! omg sorry that the table was not updated, the winners are as highlighted in the picture. So unfortunately you are not the winner this round, though you did a great job by giving the correct answer!

now the table has been updated... such a silly mistake haha

No problems!
I had fun solving the problem anyway 😹
Looking forward to the next one!

ye sure, thanks for your participation! :)

We extend our congratulations to the winners!

thanks for your sponsorship @steemstem !

Upvoted by the Minnows Accelerator Project (MAP).

This article was created by a MAP Member. Any quality blog creator can request to join the Minnows Accelerator Project too.

Read all the articles posted by MAP members.

Please upvote this comment so that MAP can continue to support Quality Content Creators.

Enovative post thanks for the sharing this post..............

Nice post, and probably an eyeopener for many. SUCCESS ALL !





喔天!!! 這對我來說都是外星文!!! 看不懂啊!! 大家都太厲害~~

真的嗎 XD 這次的比賽已經相對地容易了,是初中的數學知識啦~


Congratulations @kenchung, this post is the sixth most rewarded post (based on pending payouts) in the last 12 hours written by a Superuser account holder (accounts that hold between 1 and 10 Mega Vests). The total number of posts by Superuser account holders during this period was 853 and the total pending payments to posts in this category was $5226.23. To see the full list of highest paid posts across all accounts categories, click here.

If you do not wish to receive these messages in future, please reply stop to this comment.

A wonderful post. @kenchung followedd

安慰奖是随机的吗。。。:( 下次我争取快一些。

加油啊 :)