1. Engineering
  2. Computer Science
  3. write a function named primefactors that takes an integer as...

Question: write a function named primefactors that takes an integer as...

Question details

Write a function named prime_factors that takes an integer as a parameter and returns a list containing all its smallest prime factors. For example, the number 120 has prime factors of 2, 2, 2, 3, 5, so the function should return: [2, 2, 2, 3, 5] For example: Test Result print(prime_factors(120)) [2, 2, 2, 3, 5] print(prime_factors(26)) [2, 13]

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution