Back to classes

Practice problems / Java Fundamentals

Java Fundamentals

0/5 solved

Prime Factorization

Easy

Read a single positive integer from stdin and print its prime factorization.

Input format: one line holding a single integer n, where n > 1.

Output format: one line listing every prime factor in ascending order, joined by * (a star with one space on each side).

For example, 360 factors into 2 * 2 * 2 * 3 * 3 * 5.

Constraints

  • Input is a single integer greater than 1
  • Print the prime factors in ascending order
  • Join the factors with a star, with one space on each side

Examples

InputExpected Output
3602 * 2 * 2 * 3 * 3 * 5
322 * 2 * 2 * 2 * 2
142 * 7

Write your solution and click “Run tests” to see results here.