Answer to Question #349550 in Python for ravi

Question #349550

A number is Expensive if the number of digits of its prime factorization (including exponents greater than 1) is greater than the total digits of the number itself. Given an integer Implement a function that returns a string: If the number of digits of the prime factorization (including exponents greater than 1) is equal to the number of digits of N print Equal If the number of digits of the prime factorization (including exponents greater than 1) is lower than the number of digits of N print Cheap print None of the above if none of the two above conditions is true



1
Expert's answer
2022-06-13T08:30:09-0400

Answer to this question:

def factorization(n):
   i = 2
   ret = []
   while i * i <= n:
       while n % i == 0:
           ret.append(i)
           n = n / i
       i = i + 1
   if n > 1:
       ret.append(int(n))
   return ret
    
n=int(input("Please enter an integer: "))
fac_list=factorization(n)
if len(str(n))==len(fac_list):
    print('Eqal')
else:
    if len(str(n))<len(fac_list):
        print('Cheap')
    else:
        print('None')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS