Al had forgotten his locker combination and was going to be late for class.
But he was able to remember the following things:
 Each of the three numbers of the combination can be anywhere between 1 and 39 inclusive.
 Each one was different and the sum of the first two numbers was 42. The last two numbers differed by only two, and all three numbers were primes.
His friend remembered the combination and told him, "If you take the three numbers of your combination and multiply them together, the last digit of the product will be ....", and then whispered something in his ear.
With that, Al was able to deduce his combination and open his locker.
What was his combination?
10 for A=1 to 12
20 for B=1 to 12
30 for C=1 to 12
35 P1=prm(A):P2=prm(B):P3=prm(C):
40 if P1+P2=42 and abs(P3P2)=2 then
50 :if A<>B and B<>C and A<>C then
60 :Prod=P1*P2*P3
70 :print using(8,0),P1;P2;P3;Prod
80 next
90 next
100 next
shows the possibilities suiting both clues 1 and 2:
product
11 31 29 9889
13 29 31 11687
23 19 17 7429
29 13 11 4147
31 11 13 4433
37 5 3 555
37 5 7 1295
The friend must have whispered "3" into Al's ear, cluing him that his combination was 31, 11, 13.

Posted by Charlie
on 20130723 12:21:01 