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)
Note that part (3) asks for the entire list of integers for which D(i) = "abba", for the 4 digit Palindrome which is the arithmetic derivative of the most integers.
And, for reference, here are the Python functions I wrote to get prime factors and to check if an integer is prime.
def prime_factor(n):
""" for integer n, return a list of all the prime factors """
top = n // 2
factors = []
for i in range(2,top+1):
while n/i % 1 == 0:
factors.append(int(i))
n = n/i
if n == 1:
return factors
if n != 1:
factors.append(int(n))
return factors
def isprime(n):
'''check if integer n is a prime'''
n = abs(int(n))
if n < 2:
return False
if n == 2:
return True
if not n & 1:
return False
for x in range(3, int(n**0.5)+1, 2):
if n % x == 0:
return False
return True
|
Posted by Larry
on 2022-06-10 15:05:44 |