Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 4b: Prime Factors (4 points) The fundamental theorem of arithmetic states that any integer greater than one can be represented as a product of
Question 4b: Prime Factors (4 points) The fundamental theorem of arithmetic states that any integer greater than one can be represented as a product of prime factors. For instance, the number 12 is composed of the prime factors 23 12. Any prime number, such as 23 simply has itself as its only factor: 23-23. Knowing this, write a function prime_factors(n) which returns the list of prime factors in ascending order for a given integer greater than 1 For example, prime_factors (12) should return [2,2,3] In [4]: def prime_factors (n): In [SJ: prime_factors(23)[23] out[5]: True In [6]: prime_factors23,3,3,3] Out[6]: False In [7]: prime_factors(700) [2,2,5,5,7 out[7]: False In [8]: prime_factors(19**3) 19,19,19 Out[8]: False
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started