Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Fundamental Theorem of Arithmetic tells us that every positive integer n, can be expressed uniquely as a product of primes in non-decreasing order. Implement

The Fundamental Theorem of Arithmetic tells us that every positive integer n, can be expressed uniquely as a product of primes in non-decreasing order. Implement the method covered in class (and not any other method), for finding prime factorizations of integers. The function below should take in an integer n, and return a list of the prime factors of n. def factorize(n): # Provide a correct implementation for this function return []

Test

result1 = factorize(2016) expected1 = [2, 2, 2, 2, 2, 3, 3, 7] print "Prime factorization of 2016:\t\t", result1 check(result1, expected1)

result2 = factorize(2017) expected2 = [2017] print "Prime factorization of 2017:\t\t", result2 check(result2, expected2)

result3 = factorize(999999999990) expected3 = [2, 3, 3, 5, 21649, 513239] print "Prime factorization of 999999999990:\t", result3 check(result3, expected3)

result4 = factorize(999999999989) expected4 = [999999999989] print "Prime factorization of 999999999989:\t", result4 check(result4, expected4)

print "Overall factorize functionality" check([result1, result2, result3, result4], [expected1, expected2, expected3, expected4])

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions