Please specify how many positive integers display the following features:
a. The number is below 10^12.
b. It is a multiple of 225.
c. Its decimal representation involves only two distinct digits.
Provide a justification of your result..
(In reply to
Analytic solution by Larry)
Excellent analytic solution!
I had bypassed a computer solution, going directly to an analytic one, but I neglected the cases of smaller than 12-digit numbers other than those where zero was one of the digits (00 and 50), reducing my total.
I had figured a computer solution would take too long, and apparently I was right, at least using Matlab. I translated your program and tried for 9-digit limit:
power=9;
big=10^power-1;
myList=[""]; count=0;
for i=225:225:big
s=char(string(i));
if length(unique(s))~=2
continue
end
x=string(unique(s));
if ~ismember(x,myList)
myList=[myList x];
end
count=count+1;
end
disp([power count])
disp(myList(2:end))
It took half a minute to come up with
9 272
"25" "09" "03" "57" "06"
If going to 12-digit numbers takes 1000 times as long, that's 500 minutes or over 8 hours.
|
Posted by Charlie
on 2022-04-12 12:37:05 |