id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

david.white@denison.edu cs111fall2019 > factorization
prev  |  next  |  chance

Write a function that will return the unique prime factorization of a positive integer. Each positive integer has such a factorization; you should return it as a list of integers, with the smallest integers first. So the factorization of 30 is [2, 3, 5] because 2 * 3 * 5 = 30. It might seem strange, but the prime factorization of 1 is the empty list. You need not worry about 0 and negative numbers; the input is guaranteed to be a positive integer.


factorization(30) → [2, 3, 5]
factorization(24) → [2, 2, 2, 3]
factorization(99) → [3, 3, 11]

...Save, Compile, Run (ctrl-enter)

def factorization(n):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Difficulty: 85 Post-solution available

Copyright Nick Parlante 2017 - privacy