← Back to challenges

Prime Divisors

PythonHardmathalgorithmsnumbers

Instructions

Given a number, return all its prime divisors in a list. Create a function that takes a number as an argument and returns all its prime divisors.

To illustrate:

  • If n = 27
  • All divisors are: [3, 9, 27]
  • Finally, from that list of divisors, return the prime ones: [3]

Examples

prime_divisors(27) ➞ [3]

prime_divisors(99) ➞ [3, 11]

prime_divisors(3457) ➞ [3457]

Notes

N/A

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.