00:01
Okay, in this problem, we're looking to build a program that will find the prime factors of any number.
00:09
And i'm going to use two variables.
00:12
I'll call one current factor and start off with two because that's our lowest prime number.
00:18
And i'm going to say answer string and start that off as a blank answer string.
00:27
And then we're going to get a number from the user.
00:33
And i'll ask for input and integer to be factored.
00:47
And that'll get us a number from the user.
00:50
And what we're going to do is whenever we find a prime factor, we're going to divide the number by the prime factor.
00:56
We're going to keep doing that until number becomes one.
01:00
And so i can use a while loop.
01:04
As long as that number is greater than one, i know i still have work to do.
01:10
And so the first thing i'm going to do is going to test to see if the number, whatever number i'm at, is evenly divisible by the current factor.
01:20
So i'm going to use modulo division divided by current factor.
01:29
And if that is exactly equal to 0 ,000, then i know that it evenly divides and i want to do two things when that happens.
01:38
First is i want to update my answer string by adding the current factor to it.
01:48
And so i've got to convert current factor to a string.
01:56
And the second thing i need to do is i need to make my number smaller by dividing it by the current factor.
02:05
And i know that's still going to be an infinite number smaller.
02:07
Integer because i made sure that it divides equally.
02:14
If for some reason i don't find, for some reason that the number isn't equally divisible by current factor, then i need a different current factor.
02:27
So i'm gonna say current factor.
02:31
And all i'm gonna do, i'm not gonna try to keep track of what all the primes are.
02:34
I'm just going to increment this by one...