N is a 7-digit positive integer whose product of the digits is 20160.
Determine the probability that the sum of the digits of N is a perfect square.
Such 7-digit integers don't contain a zero, otherwise the product of the digits would be zero. The below table lists the 14 possible combinations of digits that lead to that product, followed by the number of ways those digits can be arranged to form such a number; not all these are the same as some have double or triple occurrences of one or more of the same digits.
To the right of the number of ways of arranging them, appears the sum of the digits, and then the square root of that sum to easily see that only one if them is a perfect square -- 36, for the combination 1, 2, 4, 5, 7, 8, 9. Having no duplicates it makes up the arrangement the maximum, 5040, number of times. The total of the "ways" column is 28,560 so the probability that a given one of such numbers will have a sod that's a perfect square, that is, 36, is 5040/28560 = 3/17 ~= 0.176470588235294.
List of Unique
digits Perms sod square root of sod
1 1 5 7 8 8 9 1260 39 6.244997998398
1 2 4 5 7 8 9 5040 36 6.000000000000
1 2 5 6 6 7 8 2520 35 5.916079783100
1 3 3 5 7 8 8 1260 35 5.916079783100
1 3 4 5 6 7 8 5040 34 5.830951894845
1 4 4 4 5 7 9 840 34 5.830951894845
1 4 4 5 6 6 7 1260 33 5.744562646538
2 2 2 5 7 8 9 840 35 5.916079783100
2 2 3 5 6 7 8 2520 33 5.744562646538
2 2 4 4 5 7 9 1260 33 5.744562646538
2 2 4 5 6 6 7 1260 32 5.656854249492
2 3 3 4 5 7 8 2520 32 5.656854249492
2 3 4 4 5 6 7 2520 31 5.567764362830
3 3 4 4 4 5 7 420 30 5.477225575052
-----
28560
>> 504/2856
ans =
0.176470588235294
>> sym(504/2856)
ans =
3/17
>>
The program:
clearvars,clc
global factList remain currfact
factList=[]; currfact=[];
remain=20160;
addon;
totup=0;
for i=1:size(factList,1)
s=sum(factList(i,:));
sr=sqrt(s);
p=uniqueperms(factList(i,:));
totup=totup+length(p);
fprintf('%2d',factList(i,:));
fprintf('%7d',length(p));
fprintf('%5d %15.12f\n' ,s,sr);
end
disp(totup);
disp(length(factList));
function addon()
global factList remain currfact
if isempty(currfact)
st=1;
else
st=currfact(end);
end
for newdig=st:9
if mod(remain,newdig)==0
currfact=[currfact newdig];
remain=remain/newdig;
if length(currfact)<7
addon
else
if remain==1
factList=[factList; currfact];
end
end
remain=remain*newdig;
currfact=currfact(1:end-1);
end
end
end
|
Posted by Charlie
on 2022-08-19 10:55:53 |