Problems & Puzzles: Puzzles

Puzzle 121. THE  LEGEND  OF  YANG  HUI

I have chosen as the last puzzle of the current millennium, one issue from a chapter of the book in preparation of my friend Luis Rodríguez - entitled "The World of Prime Numbers" - with his kindly and generous permission.

The chosen puzzle deals with an ancient puzzle supposedly posed by the Emperor Sung to the mathematician Yang Hui.

In Rodríguez's own words: 

"...After a laborious work , Yang Hui could finish in the year 1275 his book 'Hsu Ku Chai Chi Suan Fa' (Continuation of Ancient Mathematical Methods for Elucidating the Strange Properties of Numbers). Among other matters this book is about magic squares. He gives the instructions for construct magic squares of order 3, 4 and 5.

The day he presented the book to old Emperor Sung- an enthusiast of mathematics Yang Hui said: Majesty, here is my gift : a magic square of numbers in arithmetic progression such that if you add one to each cell results another of prime numbers only.

1668 198 1248   1669 199 1249
618 1038 1458 +1--> 619 1039 1459
828 1878 408   829 1879 409

(Constant difference = 210)

Enchanted the Emperor rewarded him with a splendid steed and said to him afterwards: 'But now, I observe that if one is subtracted to each cell, not all of they results primes.'
If you bring me a magic square of numbers in arithmetic progression where there results primes either we add or subtract one, I shall give you a precious villa in the country
of your dreams : Kuei-lin, at the border of Li river.

Mounting swiftly on his horse, Yang Hui was lost in the distance.... Still the Emperor is waiting for the return of Yang Hui and his super twin-magic square...".


Up to here we follow the Rodríguez's literary thread.

As you can see, in order to get the asked magic square we need to discover at least nine Twin primes in Arithmetic Progression. As a matter of fact here we are talking about of a double arithmetic progression, both with the same path (distance) and differing member to member by two (2). A kind of arithmetic DNA structure...

Question 1: Get one/the least (**) solution to the Emperor Sun's request.
Question 2: Get K Twin primes in A.P. for K>9 (***)

Note (*): As a matter of fact only  1667, 197, 617, 827 & 1877 are primes.
Note (**): 'the least'  means here the solution with the minimal largest prime of both progressions.
Note (***): Probably you may think that 9 Twin primes in A.P. are too hard to get. As an optimistic hint let me tell you that I have discovered two examples of 8 Twin primes in A.P., both examples with the largest prime less than 10^8. I can not assure that the asked 9 twin primes in A.P. are too close to the discovered 8 ones, but it could happen...
Note about the drawing: This is a collaboration of Juan Sabastián, Luis's son.


Well, the winner of the ville Kuei-Lin is Paul Jobling, and BTW he is the winner since last May. According to him (30/12/2000) "...I made the search in May of this year, for no reason other than to look for a long AP of twin primes as I had not seen anything published on them. I sent my result to the prime-l mailing list and to the Number Theory mailing list (nmbrthry)...."

All his solutions are for K = 10 being the smaller (130864+i*66391)*11#+180+-1, for i=0 to 9... where the common difference is 153363210 (=66391*11#) and provide the following solution to the Magic square asked by the Emperor Sung:




























green = smallest prime; red = largest prime

Paul adds "No doubt somebody will find the smallest example of an AP of 9 twin primes, it will be smaller than the square that I sent to you"

Regarding the method he employed Paul wrote:

"We are looking for an AP of twin primes: a +-1, a+b +-1, a+2b +-1, ..., a+(n-1)b +-1. For an AP of twin primes of length n, it is obvious that b must be a multiple of n#, the product of the primes <=n. I therefore performed the following search:

For p= the primes 11, 13, 17: For each possible x <= p#, Obtain the 1 million numbers of the form x + i.p#, 0 <= i < 1000000 Discard those i's where x+i.p#+1 or x+i.p#-1 is composite. This will leave those i's where x+i.p# +- 1 is a pair of twin primes.

Search these i's for an arithmetic progression of length >= 8. The testing time was very short for p=11 and 13 (hours); for p=17 the search time was approximately 40 days on a 233Mhz PII."


Current status (30/12/2000)

Regarding the Magic square asked by the Emperor, Paul has gotten several solutions, but his smaller one probably is not the earliest.

Regarding The Least Sequences of K Twin primes in A.P. the situation is as follows:



First & lower prime of the least sequence

Last & upper prime of the sequence Auhor
















823 C.R., 12/2000




2143 Luis Rodríguez, 12/2000




2658289 C.R., 12/2000




13628983 C.R., 12/2000





P. J., 31/12/2000


302296019  (*)


P. J., 5/2000

(*) This is only the smallest known sequence...(Gennady Gusev wrote, the 16/6/01: I've been searching twin AP up to 2.1E9 and found only one AP of length 10 - that Paul Jobling found: N=10 d=153363210 A1=302296019 An=1682564911. So you may take off the word "known", it is just "the smallest".)


One day after, Paul sent the following & smaller sequence now for K=9:

(81868+i*11362)*11#+1050+-1, leading to the square

372839670 241608570 267854790
189116130 294101010 399085890
320347230 346593450 215362350

Common difference = 11362*11# = 26246220

He can not assure yet that this is the earliest sequence we are looking for.


But the 1/1/2001 Paul closed the question. How?

"I have checked my calculations, and I find that the AP of 9 twin primes that I sent is the smallest. Specifically, I tested (A+Bi).7#+C for A+Bi<2000000, and found only one AP of length 9: (900553+i*124982).7# + 0 +/-1. This is the same as (81868+i*11362)*11#+1050+/-1."

Then, the absolute earlier solution to the Emperor question is:

372839669 241608569 267854789   372839670 241608570 267854790   372839671 241608571 267854791
189116129 294101009 399085889 ß-1 189116130 294101010 399085890 +1ŕ 189116131 294101011 399085891
320347229 346593449 215362349   320347230 346593450 215362350   320347231 346593451 215362351

A problem supposedly closed 725 years later... not a bad problem...


Records   |  Conjectures  |  Problems  |  Puzzles