Challenge: Prime Factor

Check your understanding of prime factors.

Problem statement

Prime factors are the combinations of the smallest prime numbers that, when multiplied together, will produce the original number. Consider the following examples:

  • Prime factors of 44 are: 2x22 x 2

  • Prime factors of 77 are: 77

  • Prime factors of 3030 are: 5x3x25 x 3 x 2

  • Prime factors of 4040 are: 5x2x2x25 x 2 x 2 x 2

  • Prime factors of 5050 are: 5x5x25 x 5 x 2

Implement your solution in three projects created for you:

  1. A class library in the PrimeFactorsLib project with a static class and static method named PrimeFactors that, when passed an int variable as a parameter returns a string showing its prime factors.

  2. A unit test in the unit test project named PrimeFactorsTests with a few suitable unit tests.

  3. A console application to use in the PrimeFactorsApp project.

To keep it simple, assume that the largest number entered will be 10001000.

Expected output

The result of running your console app should look something like this:

Get hands-on with 1400+ tech skills courses.