Consider the following (simplified) definition of the "Arithmetic Derivative" for n in positive integers:
D(0) = D(1) = 0
D(prime) = 1
D(ab) = D(a)*b + D(b)*a
Examples:
D(7) = 1 because 7 is prime.
D(30) = D(5*6) = D(5)*6 + 5*D(6) = 1*6 + 5*D(2*3)
= 6 + 5*[D(2)*3+2*D(3)] = 6 + 5*5 = 31, so ...
D(30) = 31
D(58) = 31 (More than one integer can have the same Arithmetic Derivative.)
(1). Find n and D(n) (n up to 5 digits) such that D(n) is the largest.
(2). Find n and D(n) (n up to 5 digits and not prime) such that the ratio D(n)/n is the largest.
(3). Which 4-digit Palindrome is the Arithmetic Derivative of the most 4-digit positive integers, and list them.
(4). For what set of n is n = D(n)
(In reply to
bits and pieces by Larry)
changing a section of code to
pal=[]; maxpal=0;
for j=1:upto
if isPalin(d(j)) && d(j) ~= 1
f=find(d==d(j));
ctpal=length(f);
pal(end+1)=d(j);
disp([j d(j) ctpal])
if ctpal>maxpal
maxpal=ctpal;
end
end
end
disp(' ')
pal=sort(pal);
pal'
disp(' ')
for j=1:upto
if isPalin(d(j)) && d(j) ~= 1
f=find(d==d(j));
ctpal=length(f);
pal(end+1)=d(j);
if ctpal==maxpal
disp([j d(j) ctpal])
end
end
end
disp(' ')
produces a list of n, D and maxtimes
2382 1991 13
2830 1991 13
3406 1991 13
3502 1991 13
4137 1991 13
4947 1991 13
5217 1991 13
5705 1991 13
6955 1991 13
7505 1991 13
7705 1991 13
7955 1991 13
9821 1991 13
for n up to 9999
and
532 636 29
3155 636 29
10523 636 29
11723 636 29
14099 636 29
17603 636 29
22163 636 29
25499 636 29
34043 636 29
38123 636 29
41099 636 29
44003 636 29
48683 636 29
59099 636 29
64643 636 29
68363 636 29
72563 636 29
75203 636 29
80099 636 29
81803 636 29
85499 636 29
86483 636 29
92843 636 29
94883 636 29
97403 636 29
98099 636 29
98723 636 29
99443 636 29
99899 636 29
for the up to 99999 version
|
Posted by Charlie
on 2022-06-10 15:50:51 |