All tasks
Mediummathloops

Prime Factorization

Time limit 2 s · Memory 64 MBAcceptance: —Solved by: 0

Statement

You are given an integer n. Print its prime factors in non-decreasing order, repeating each factor as many times as it divides n, on one line separated by spaces. For example, for 12 the answer is: 2 2 3.

Examples

Example 1
Input
12
Output
2 2 3
Example 2
Input
7
Output
7

Constraints

  • 2 ≤ n ≤ 10^12
Solve this task to unlock the editorial.

AI tutor

Stuck? Get a nudge — the tutor explains the idea, it never hands you the solution.