Prime Factorization - aloalgo

Prime Factorization

Easy

You are given a positive integer n. Your task is to find its prime factorization, which is the decomposition of n into a product of its prime numbers. The result should be a list of these prime factors, sorted in non-decreasing order.

Example 1

Input
12
Output
[2, 2, 3]
Explanation:

12 is divisible by 2, resulting in 6. 6 is divisible by 2, resulting in 3. 3 is a prime number. So the prime factors are 2, 2, and 3.

Example 2

Input
7
Output
[7]
Explanation:

7 is a prime number, so its only prime factor is itself.

Example 3

Input
1
Output
[]
Explanation:

The number 1 has no prime factors.

Loading...
Input
12
Output
[2, 2, 3]

Hello! I am your ✨ AI assistant. I can provide you hints, explanations, give feedback on your code, and more. Just ask me anything related to the problem you're working on!