The digital product P(N) of an integer N is the product of its decimal digits. So P(128)=16.
Determine all sets of distinct positive integers A and B such that A = P(B)P(C) and B = P(A)P(C) for some integer C.
For each pair, A and B, give the lowest possible value for C.
The program finds values of n*P(n) for matching in the cross multiplication of A*P(B) = B*P(B), for A/P(B) = B/P(A).
When found, A/P(B) or its equivalent B/P(A) must be an integer and its largest prime factor must be under 10.
nList=[]; pList=[];
for n=1:999999
ns=num2str(n);
if ~contains(ns,'0')
nList(end+1)=n;
pList(end+1)=n*prod(ns-48);
end
end
[pList,idx] = sort(pList);
nList=nList(idx);
clc
for i=1:length(nList)-1
if pList(i)==pList(i+1)
a=nList(i);b=pList(i+1)/nList(i+1);
if a/b==round(a/b) && max(factor(a/b))<10
fprintf('%11d %11d %11d\n',[nList(i),nList(i+1),a/b])
end
end
end
finds only
A B P(C)
24 32 4
48 64 2
288 384 3
As it turns out, P(C) is the same as the smallest C in each instance.
24 = 6 * 4
32 = 8 * 4
48 = 24 * 2
64 = 32 * 2
288 = 96 * 3
384 = 128 * 3
Of course A and B can be interchanged.
|
Posted by Charlie
on 2024-04-11 13:35:10 |