**greil@guug.guug.de (Anton Greil)** (08/02/90)

Can you solve the following puzzle by SQL? "Here is an arithmetical problem which is belonging to the great classics. Two natural numbers were selected which are greater than 1 and less than 100. The sum of these two numbers was told Mr. S, the product of the numbers was told Mr. P. Each of the two men doesn't know the number of the other. Mr. P rings up Mr. S: P: I can't find the two numbers. S: I knew, that you would not succeed. P: Oh ... But now, I know them! S: In this case, I know them too." (from: Jaques ARSAC: Jeux et casse-tete a programmer, Paris 1985 Computer Denkspiele, selbst programmiert, Muenchen 1987) There is just one solution for this problem!

**jkenton@pinocchio.encore.com (Jeff Kenton)** (08/17/90)

From article <125@guug.guug.de>, by greil@guug.guug.de (Anton Greil): > > Can you solve the following puzzle by SQL? > > "Here is an arithmetical problem which is belonging to the great > classics. Two natural numbers were selected which are greater > than 1 and less than 100. The sum of these two numbers was told > Mr. S, the product of the numbers was told Mr. P. > > Each of the two men doesn't know the number of the other. Mr. P > rings up Mr. S: > > P: I can't find the two numbers. > S: I knew, that you would not succeed. > P: Oh ... But now, I know them! > S: In this case, I know them too." > The two numbers are 3 and 14. Solved by following the clues: > P: I can't find the two numbers. Therefore, the PRODUCT has at least 3 prime factors, all less than 50. > S: I knew, that you would not succeed. Therefore, all decompositions of the SUM into two numbers must produce a product which satisfies the condition above. This leaves 11, 17, 23, 27, 29, 35, 41, 47 and 51. > P: Oh ... But now, I know them! Therefore, of all the factorings of the PRODUCT into two numbers, in only one case is the sum of those numbers in the list above. > S: In this case, I know them too." Therefore, of all decompositions of the SUM into two numbers exactly one produces a product which, when factored into pairs of numbers, has only one of those pairs whose sum is in the list above. Only the sum 17 satisfies this last condition (with the pair 4 + 13). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - jeff kenton --- temporarily at jkenton@pinocchio.encore.com --- always at (617) 894-4508 --- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

**cosell@bbn.com (Bernie Cosell)** (08/19/90)

jkenton@pinocchio.encore.com (Jeff Kenton) writes: }From article <125@guug.guug.de>, by greil@guug.guug.de (Anton Greil): }> }> Can you solve the following puzzle by SQL? }> }> "Here is an arithmetical problem which is belonging to the great }> classics. Two natural numbers were selected which are greater }> than 1 and less than 100. The sum of these two numbers was told }> Mr. S, the product of the numbers was told Mr. P. }> }> Each of the two men doesn't know the number of the other. Mr. P }> rings up Mr. S: }> }> P: I can't find the two numbers. }> S: I knew, that you would not succeed. }> P: Oh ... But now, I know them! }> S: In this case, I know them too." }... Solved by following the clues: }> P: I can't find the two numbers. }Therefore, the PRODUCT has at least 3 prime factors, all less than 50. ... But he didn't ASK to have it solved by 'following the clues' [not to mention the explicit request about 'SQL', I assume from his mentioning that it is a classic that he is familiar with the traditional solution There is no problem with posting it, of course, but we have NOT yet solved the problem he posed. It is pretty mindboggling that one could specify an SQL query that would return JUST the pair of numbers that solves theproblem... The matter at hand is NOT to solve the puzzle, per se, but to come up with *SQL* to solve it... /Bernie\