Some numbers remain numbers when turned upside down (using digits 0125689, with no final 0's):
1, 2, 5, 6, 8, 9, 11, 12, … etc
IF a1=1, a2=2, a3=5,... a8=12,…, etc
a.Evaluate a100
b. Evaluate a1000
c. If an= 888, what is n?
valid$ = "0125689"
PRINT
FOR i = 1 TO 19000
s$ = LTRIM$(STR$(i))
found = 1
FOR j = 1 TO LEN(s$)
IF INSTR(valid$, MID$(s$, j, 1)) = 0 THEN found = 0
NEXT
IF RIGHT$(s$, 1) = "0" THEN found = 0
IF found THEN
ct = ct + 1
IF ct < 15 OR ct = 100 OR ct = 1000 OR i = 888 THEN PRINT ct, i:
END IF
NEXT
finds
n a(n)
1 1
2 2
3 5
4 6
5 8
6 9
7 11
8 12
9 15
10 16
11 18
12 19
13 21
14 22
100 226
245 888
1000 5286
So:
a. 226
b. 5286
c. 245
The proscription on terminal zero prevents easy use of an isomorphism with base-7 numbers, where we'd just assign the valid digits to the successive base-7 digits and use base-conversion algorithms.
|
Posted by Charlie
on 2014-04-11 15:47:31 |