Determine all possible value(s) of a non-leading zero, 5-digit positive integer N that satisfy each of these given conditions:
(i) Product of the digits of N is equal to the sum of its digits.
(ii) N is divisible by the sum of its digits.
(iii) N does NOT contain the digit 3.
Added for completeness:
What is the total number of values of N if we disregard condition (iii)?
for n=10000:99999
s=char(string(n));
prod=1; sod=0;
good=true;
for i=1:5
prod=prod*str2num(s(i));
sod=sod+str2num(s(i));
end
if good==false
continue
end
if prod==sod
if mod(n,sod)==0
disp([n sod])
end
end
end
The answer, from the list below, is 22112, whose sod is 8 as is its product of digits, and it's divisible by 8 as well.
By disregarding rule iii, we get the following list, where 9 is the sod, pod and divisor rather than the 8 of the preceding answer:
11133 9
11313 9
11331 9
13113 9
13131 9
13311 9
22112 8
31113 9
31131 9
31311 9
33111 9
Every placement of two 3's and three 1's is a solution because of the divisibility rule for 9.
|
Posted by Charlie
on 2022-04-24 09:42:46 |