A 10-digit number 2404563210 has an interesting feature: reading from left to right - any k-digit string is divisible by k.
No big deal ! IMHO there are 2492 numbers like that.
At least one of them utilizes only 3 distinct digits.
Find this number.
(In reply to
interesting aside by Charlie)
According to the online reference, for lengths 20 through 25, the numbers of qualifying numbers continues downward: 44, 18, 12, 6, 3 and 1.
The 44 for length 20 are:
10805480103600001800
12005424904858560080
12360600901222567200
14440864504822563660
14480488803690081000
14485808700090082880
22200640209678085240
22560024608422560080
22885248606094567840
24045072304890087020
24085888200010566020
26160688807246564240
30680448304870560640
34200600302442087000
36085288503684007860
38160648900010566000
40285216807290082800
40525240503678082220
42960680103642085800
46240816501236007840
48000688208466084040
48325208404858569060
54045600301294560040
56480480100072009000
56725200004858561860
58565432706046569020
60645696309646565480
64885248901200004280
66325288502466081020
72645656402410567240
74125808108436004200
74440800907200000020
78925288508430084020
80480400308490088860
82285288206030082860
82525248003646560660
84000072607234561840
84045016803678089480
84680472602446567280
90685840509684000060
96360048906030082840
96600008703646560640
96600072602418082260
96685896604836004260
The 18 for length 21 are:
123606009012225672009
144408645048225636603
144858087000900828807
240858882000105660207
306804483048705606405
342006003024420870009
360852885036840078603
402852168072900828009
564804801000720090006
567252000048585618606
663252885024660810201
726456564024105672408
741258081084360042000
846804726024465672807
906858405096840000609
963600489060300828408
966000087036465606405
966858966048360042609
The 12 for length 22 are:
1236060090122256720090
1444086450482256366038
2408588820001056602074
3420060030244208700096
3608528850368400786036
4028521680729008280092
5672520000485856186064
7264565640241056724082
7412580810843600420006
8468047260244656728072
9068584050968400006092
9668589660483600426096
The 6 for length 23 are:
12360600901222567200901
14440864504822563660381
24085888200010566020746
36085288503684007860367
40285216807290082800921
72645656402410567240820
The 3 for length 24 are:
144408645048225636603816
360852885036840078603672
402852168072900828009216
The UBASIC program is as follows. The commented-out lines (with single quote or apostrophe (') starting the comment) were for counting unique digits. I didn't get as far as getting this feature to work; that's why the count of unique digits is not done.
4 kill "only3.txt"
5 open "only3.txt" for output as #2
10 dim Used(9)
20 gosub *AddOn(1)
30 close #2
40 end
50
60 *AddOn(Wh)
70 local SaveN,St,Newd,R,UCt,S$
80 SaveN=N
90 if Wh=1 then St=1 else St=0
100 for Newd=St to 9
110 N=10*SaveN+Newd
120 R=N@Wh
130 if R=0 then
140 :if Wh=23 then
150 :'UCt=0 ':erase Used():dim Used(9)
160 :'S$=cutspc(str(N))
170 :'for I=1 to len(S)
180 :'if Used(val(mid(S,I,1)))=0 then UCt=UCt+1:endif
190 :'Used(val(mid(S,I,1)))=1
200 :'next
210 :print N:print #2, N
220 :else
230 :gosub *AddOn(Wh+1)
240 :endif
250 next
260 N=SaveN
270 return
|
Posted by Charlie
on 2018-05-18 13:58:44 |