Here is a numbered list of statements, some true, some false, which refer to a specific number (unique positive integer, base 10).
It just so happens that if a statement is true then its index number appears among the number's digits, and if a statement is false then its index number does not appear among the number's digits.
- The sum of the number's digits is a prime.
- The product of the number's digits is odd.
- Each of the number's digits is less than the next digit (if there is one).
- No two of the number's digits are equal.
- None of the number's digits is greater than 4.
- The number has fewer than 6 digits.
- The product of the number's digits is not divisible by 6.
- The number is even.
- No two of the number's digits differ by 1.
- At least one of the number's digits is equal to the sum of two other digits. (Any of the digits may be equal, as long as all 3 digits are distinct... for example: {2, 2, 4} or {2, 3, 5} )
Find the number.
8005 found by:
5 dim DigUsed(20):dim Dig$(10)
10 for N=1 to 99999999
20 N$=cutlspc(str(N))
25 TDig=0:PDig=1
26 erase DigUsed(),Dig$()
27 dim DigUsed(20):dim Dig$(10)
28 Dig$(0)=""
30 NumDigs=len(N$)
31 Mono=1:Adj=0:Eq=0:Gt4=0
32 for I=1 to len(N$)
40 Dig$(I)=mid(N$,I,1)
45 Dig=val(Dig$(I))
46 if Dig>4 then Gt4=1
50 TDig=TDig+Dig
60 PDig=PDig*Dig
70 DigUsed(Dig)+=1
75 if DigUsed(Dig)>1 then Eq=1
80 if Dig$(I)<=Dig$(I-1) then Mono=0
90 if DigUsed(Dig+1) then Adj=1
91 if Dig>0 then if DigUsed(Dig-1) then Adj=1
200 next I
210 if (nxtprm(TDig-1)=TDig)=(DigUsed(0)=0) then goto *NotThis
220 if (PDig@2=1)=(DigUsed(1)=0) then goto *NotThis
230 if Mono=(DigUsed(2)=0) then goto *NotThis
240 if Eq=(DigUsed(3)>0) then goto *NotThis
250 if Gt4=(DigUsed(4)>0) then goto *NotThis
260 if (NumDigs<6)=(DigUsed(5)=0) then goto *NotThis
270 if (PDig@6=0)=(DigUsed(6)>0) then goto *NotThis
280 if (N@2=0)=(DigUsed(7)=0) then goto *NotThis
290 if Adj=(DigUsed(8)>0) then goto *NotThis
299 FoundSum=0
300 for I=1 to NumDigs-1
310 for J=I+1 to NumDigs
320 D1=val(Dig$(I)):D2=val(Dig$(J)):T=D1+D2
330 Du=DigUsed(T)
340 if D1=T then Du=Du-1
350 if D2=T then Du=Du-1
360 if Du>0 then FoundSum=1:cancel for:cancel for:goto *ItsSum
400 next J
410 next I
420 *ItsSum
430 if FoundSum=(DigUsed(9)=0) then goto *NotThis
990 print N
999 *NotThis
1000 next N
|
Posted by Charlie
on 2004-07-19 15:09:48 |