Solution: Prime Factor
Look at the solution to the previous challenge.
We'll cover the following
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
are: Prime factors of
are: Prime factors of
are: Prime factors of
are: Prime factors of
are:
Implement your solution in three projects created for you:
A class library in the
PrimeFactorsLib
project with a static class and static method namedPrimeFactors
that, when passed anint
variable as a parameter returns astring
showing its prime factors.A unit test in the unit test project named
PrimeFactorsTests
with a few suitable unit tests.A console application to use in the
PrimeFactorsApp
project.
To keep it simple, assume that the largest number entered will be 1,000.
Step-by-step solution
Let’s look at our solution by comprehensively understanding it.
Let’s have a look at Program.cs
file:
Get hands-on with 1400+ tech skills courses.