What is the smallest pandigital number divisible by 143?
a. Consider 9-digit numbers (no zero!)
b. 10 digits - zero included.
Try to solve analytically.
a. 123586749 b. 1024576839
from
clearvars, clc
n=143*ceil(100000000/143);
while n<=999999999
ns=char(string(n));
if ~contains(ns,'0')
if length(unique(ns))==9
disp(n)
break
end
end
n=n+143 ;
end
n=143*ceil(1000000000/143);
while n<=9999999999
ns=char(string(n));
% if ~contains(ns,'0')
if length(unique(ns))==10
disp(n)
break
end
% end
n=n+143 ;
end
|
Posted by Charlie
on 2022-01-13 16:03:30 |