Ian Uy wrote:I'm lost on how to begin to tackle this problem. Please advice.
As a college student, you really should be able to do this. It's basic math.
What you will want to search for is called "prime factorization." The easiest-to-understand technique is called "trial division."
On paper, you start by writing down your large number (let's call it 'n'). Then try to think of another number which divides evenly into n without any remainder. That number is a factor of n. It's easiest to start with small numbers.
In your example, what number divides evenly into
? How about
. So write down
(those are factors of
, but not necessarily prime).
Then try to factor each number you wrote down (the
). Are there any numbers (other than 1) that divide into
evenly? No, so
is a "prime factor" of
cannot be divided any further).
How about the
. So, there is another
that is a prime factor of
. So far we have the factors of
. Now factor the
and keep going.
Keep going until you run out of numbers that can be divided evenly. Those will be your prime factors.
120 factored = 2,60 (2 is prime)
60 factored = 2,30 (2 is prime)
30 factored = 2,15 (2 is prime)
15 factored = 3,5 (both 3 and 5 are prime)
The prime factors of
are (from the parentheses above)
Now try writing that in code and see what you come up with. You can use this Table of Prime Factors
] to check your answers.