L-B number is a number with distinct non-zero digits
divisible by each of its digits e.g. 186432.
a. What is the largest LBN not containing the digit 1?
b. How many LBNs contain the digit 4?
c. Same for digit 5.
d. What is the largest LBN?
Provide your reasoning and/or program; solution by searching for answers on the web will be considered unfair…
The program does not attempt to use all 9 digits as a zeroless number can't be divisible by both 2 and 5.
digs='123456789';
largeNot1=0;
ctHas4=0;
ctHas5=0;
largest=0;
ct=0;
solset=[];
for sz= 1:8
ix=combinator(9,sz,'p'); % Finds sets of indices for permutations
for i=1:length(ix) % without replacement
ns=digs(ix(i,:));
n=str2double(ns);
good=true;
for j=1:length(ns)
if mod(n,str2double(ns(j)))~=0
good=false;
break
end
end
if good
ct=ct+1;
solset(end+1)=n;
if isempty(strfind(ns,'1'))
if n>largeNot1
largeNot1=n;
end
end
if ~isempty(strfind(ns,'4'))
ctHas4=ctHas4+1;
end
if ~isempty(strfind(ns,'5'))
ctHas5=ctHas5+1;
end
if n>largest
largest=n;
end
end
end
end
solset=sort(solset);
disp(' ')
disp(largeNot1)
disp(ctHas4 )
disp(ctHas5 )
disp(largest )
disp(ct)
disp(' ')
for i=1:length(solset)
disp(solset(i));
end
shows the following statistics:
Largest without a 1 978264
How many with a 4 339
How many with a 5 12
Largest 9867312
Total number of L-B's 548
This includes the single-digit numbers, so if it is desired not to count them, there are only 338 with a digit 4, 11 with a digit 5, and 539 altogether.
the sorted list:
1
2
3
4
5
6
7
8
9
12
15
24
36
48
124
126
128
132
135
162
168
175
184
216
248
264
312
315
324
384
396
412
432
612
624
648
672
728
735
784
816
824
864
936
1236
1248
1296
1326
1362
1368
1395
1632
1692
1764
1824
1926
1935
1962
2136
2184
2196
2316
2364
2436
2916
3126
3162
3168
3195
3216
3264
3276
3492
3612
3624
3648
3816
3864
3915
3924
4128
4172
4236
4368
4392
4632
4872
4896
4932
4968
6132
6192
6312
6324
6384
6432
6912
6984
8136
8496
8736
9126
9135
9162
9216
9315
9324
9432
9612
9648
9864
12384
12648
12768
12864
13248
13824
13896
13968
14328
14728
14832
16248
16824
17248
18264
18432
18624
18936
19368
21384
21648
21784
21864
23184
24168
24816
26184
27384
28416
29736
31248
31824
31896
31968
32184
34128
36792
37128
37296
37926
38472
39168
39816
41328
41832
42168
42816
43128
43176
46128
46872
48216
48312
61248
61824
62184
64128
68712
72184
73164
73248
73416
73962
78624
79128
79632
81264
81432
81624
81936
82416
84216
84312
84672
87192
89136
89712
91368
91476
91728
92736
93168
93816
98136
123648
123864
123984
124368
126384
129384
132648
132864
132984
134928
136248
136824
138264
138624
139248
139824
142368
143928
146328
146832
148392
148632
149328
149832
162384
163248
163824
164328
164832
167328
167832
168432
172368
183264
183624
184392
184632
186432
189432
192384
193248
193824
194328
194832
198432
213648
213864
213984
214368
216384
218736
219384
231648
231864
231984
234168
234816
236184
238416
239184
241368
243168
243768
243816
247968
248136
248976
261384
263184
273168
281736
283416
284136
291384
293184
297864
312648
312864
312984
314928
316248
316824
318264
318624
319248
319824
321648
321864
321984
324168
324816
326184
328416
329184
341928
342168
342816
346128
348192
348216
348912
349128
361248
361824
361872
362184
364128
364728
367248
376824
381264
381624
382416
384192
384216
384912
391248
391824
392184
394128
412368
413928
416328
416832
418392
418632
419328
419832
421368
423168
423816
427896
428136
428736
431928
432168
432768
432816
436128
438192
438216
438912
439128
461328
461832
463128
468312
469728
478296
478632
481392
481632
482136
483192
483216
483672
483912
486312
489312
491328
491832
493128
498312
612384
613248
613824
613872
614328
614832
618432
621384
623184
623784
627984
631248
631824
632184
634128
634872
641328
641832
643128
648312
671328
671832
681432
684312
689472
732648
732816
742896
746928
762384
768432
783216
789264
796824
813264
813624
814392
814632
816432
819432
823416
824136
824376
831264
831624
832416
834192
834216
834912
836472
841392
841632
842136
843192
843216
843912
846312
849312
861432
864312
873264
891432
894312
897624
912384
913248
913824
914328
914832
918432
921384
923184
927864
931248
931824
932184
934128
941328
941832
943128
948312
976248
978264
981432
984312
1289736
1293768
1369872
1372896
1376928
1382976
1679328
1679832
1687392
1738296
1823976
1863792
1876392
1923768
1936872
1982736
2137968
2138976
2189376
2317896
2789136
2793168
2819376
2831976
2931768
2937816
2978136
2983176
3186792
3187296
3196872
3271968
3297168
3298176
3619728
3678192
3712968
3768912
3796128
3816792
3817296
3867192
3869712
3927168
3928176
6139728
6379128
6387192
6389712
6391728
6719328
6719832
6731928
6893712
6913872
6971328
6971832
7168392
7198632
7231896
7291368
7329168
7361928
7392168
7398216
7613928
7639128
7829136
7836192
7839216
7861392
7863912
7891632
7892136
7916328
7916832
7921368
8123976
8163792
8176392
8219736
8312976
8367912
8617392
8731296
8796312
8912736
8973216
9163728
9176328
9176832
9182376
9231768
9237816
9278136
9283176
9617328
9617832
9678312
9718632
9723168
9781632
9782136
9812376
9867312
|
Posted by Charlie
on 2023-01-27 10:35:09 |