A boy met his father after his maths exam. He said, "Dad can you guess the number of students who appeared at our center?"
The following are true regarding the number
a) It has three distinct digits.
b) If you add 99 the number reverses.
He continues saying, "I have the following statements to add regarding the number."
1) It is divisible by the sum of its digits.
2) It is not prime.
3) It has only one common digit with the product of the digits.
4) The sum of the first and last digit is one more than the middle digit.
He adds further that "if I told you which of these statement(s) is/are false then you'd be able to determine the number."
Dad got it. What was the number?
4 kill "mathexam.txt"
5 open "mathexam.txt" for output as #2
10 for N=100 to 900
20 Np=N+99
30 D1=N\100
40 D2=(N\10)@10
50 D3=N@10
60 if D1=Np@10 and D2=(Np\10)@10 and D3=Np\100 and D1<>D2 and D2<>D3 and D1<>D3 then
70 :if N@(D1+D2+D3)=0 then S1=1:else S1=0:endif
80 :if nxtprm(N-1)<>N then S2=1:else S2=0:endif
90 :Pr=D1*D2*D3
100 :Prs=cutspc(str(Pr))
110 :Nstr=cutspc(str(N))
120 :Ct=0
130 :for I=1 to len(Nstr)
140 :if instr(Prs,mid(Nstr,I,1))>0 then Ct=Ct+1:endif
150 :next
160 :if Ct=1 then S3=1:else S3=0:endif
170 :if D1+D3=D2+1 then S4=1:else S4=0:endif
180 :if S1+S2+S3+S4<4 then print #2,N;S1;S2;S3;S4;S1+S2+S3+S4:endif
190 next
After restricting the numbers to those in question, the above program produced a file with, for each number, a zero for each false statement and a 1 for each true, followed by the total number of true statements. The file was sorted on the total number of true statement and on the sequence of zeros and ones representing the truth values:
859 0 0 0 0 0
293 0 0 0 0 0
839 0 0 0 0 0
829 0 0 0 0 0
263 0 0 0 0 0
617 0 0 0 0 0
809 0 0 1 0 1
283 0 0 1 0 1
607 0 0 1 0 1
647 0 0 1 0 1
213 0 1 0 0 1
798 0 1 0 0 1
627 0 1 0 0 1
819 0 1 0 0 1
142 0 1 0 0 1
718 0 1 0 0 1
657 0 1 0 0 1
879 0 1 0 0 1
596 0 1 0 0 1
354 0 1 0 0 1
586 0 1 0 0 1
546 0 1 0 0 1
384 0 1 0 0 1
394 0 1 0 0 1
536 0 1 0 0 1
415 0 1 0 0 1
495 0 1 0 0 1
435 0 1 0 0 1
869 0 1 0 0 1
485 0 1 0 1 2
475 0 1 1 0 2
425 0 1 1 0 2
768 0 1 1 0 2
758 0 1 1 0 2
526 0 1 1 0 2
849 0 1 1 0 2
374 0 1 1 0 2
748 0 1 1 0 2
172 0 1 1 0 2
728 0 1 1 0 2
314 0 1 1 0 2
304 0 1 1 0 2
273 0 1 1 0 2
637 0 1 1 0 2
253 0 1 1 0 2
203 0 1 1 0 2
687 0 1 1 0 2
697 0 1 1 0 2
708 0 1 1 0 2
182 0 1 1 0 2
162 1 1 0 0 2
576 1 1 0 0 2
516 1 1 0 0 2
132 1 1 0 0 2
324 1 1 0 0 2
465 1 1 0 0 2
364 1 1 0 1 3
243 1 1 0 1 3
152 1 1 1 0 3
405 1 1 1 0 3
506 1 1 1 0 3
738 1 1 1 0 3
192 1 1 1 0 3
102 1 1 1 0 3
485 has the only unique set of truth values.
|
Posted by Charlie
on 2006-04-21 13:51:45 |