primeFac (Perkovic, Problem 5.42) Write a function primeFac that computes the prime factorization of a number: • it accepts a single argument, an integer greater than 1 it returns a list containing the prime factorization o each number in the list is a prime number greater than 1 o the product of the numbers in the list is the original number o the factors are listed in non-decreasing order Sample usage: 1 >>> primeFac(5) 2 [5] 3 >>> primeFac(72) [2, 2, 2, 3, 3] >>> primeFac(72)= [2, 2, 2, 3, 3] 4. True 7 >>> [ (i,primeFac (i)) fori in range (10,300,23)] 8 [(10, [2, 5]), (33, [3, 11]), (56, [2, 2, 2, 7]), (79, [79]), (102, [2, 3, 17]), (125, [5, 5, 5]), (148, [2, 2, 37]), (171, [3, 3, 19]), (194, [2, 97]), (217, [7, 31]), (240, [2, 2, 2, 2, 3, 5]), (263, [263]), (286, [2, 11, 13])] >>> [ (i,primeFac (i)) fori in range (3,300,31)] [(3, [3]), (34, [2, 17]), (65, [5, 13]), (96, [2, 2, 2, 2, 2, 3]), (127, 9. 10 [127]), (158, [2, 79]), (189, [3, 3, 3, 7]), (220, [2, 2, 5, 11]D, (251,

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
In Python IDLE: How would I write a function for the problem in the attached image?
primeFac
(Perkovic, Problem 5.42) Write a function primeFac that computes the prime factorization of a
number:
it accepts a single argument, an integer greater than 1
it returns a list containing the prime factorization
o each number in the list is a prime number greater than 1
o the product of the numbers in the list is the original number
o the factors are listed in non-decreasing order
Sample usage:
1
>>> primeFac(5)
2
[5]
3
>>> primeFac(72)
4
[2, 2, 2, 3, 3]
>>> primeFac(72)==[2, 2, 2, 3, 3]
True
>>> [ (i,primeFac (i)) fori in range (10,300,23)]
[(10, [2, 5]D, (33, [3, 11]), (56, [2, 2, 2, 7]), (79, [79]), (102, [2, 3,
17]), (125, [5, 5, 5]), (148, [2, 2, 37]), (171, [3, 3, 19]), (194, [2,
97]), (217, [7, 31]), (240, [2, 2, 2, 2, 3, 5]), (263, [263]), (286, [2, 11,
13])]
7
8
>>> [ (i,primeFac(i)) fori in range (3,300,31)]
[(3, [3]), (34, [2, 17]), (65, [5, 13]), (96, [2, 2, 2, 2, 2, 3], (127,
[127]), (158, [2, 79]), (189, [3, 3, 3, 7]), (220, [2, 2, 5, 11], (251,
9.
10
[2511)
(282
[?
3
471)1
Transcribed Image Text:primeFac (Perkovic, Problem 5.42) Write a function primeFac that computes the prime factorization of a number: it accepts a single argument, an integer greater than 1 it returns a list containing the prime factorization o each number in the list is a prime number greater than 1 o the product of the numbers in the list is the original number o the factors are listed in non-decreasing order Sample usage: 1 >>> primeFac(5) 2 [5] 3 >>> primeFac(72) 4 [2, 2, 2, 3, 3] >>> primeFac(72)==[2, 2, 2, 3, 3] True >>> [ (i,primeFac (i)) fori in range (10,300,23)] [(10, [2, 5]D, (33, [3, 11]), (56, [2, 2, 2, 7]), (79, [79]), (102, [2, 3, 17]), (125, [5, 5, 5]), (148, [2, 2, 37]), (171, [3, 3, 19]), (194, [2, 97]), (217, [7, 31]), (240, [2, 2, 2, 2, 3, 5]), (263, [263]), (286, [2, 11, 13])] 7 8 >>> [ (i,primeFac(i)) fori in range (3,300,31)] [(3, [3]), (34, [2, 17]), (65, [5, 13]), (96, [2, 2, 2, 2, 2, 3], (127, [127]), (158, [2, 79]), (189, [3, 3, 3, 7]), (220, [2, 2, 5, 11], (251, 9. 10 [2511) (282 [? 3 471)1
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY