Sagot :
The simplest method is to repeatedly divide the number by the lowest prime number in your list of prime numbers until it is no longer a factor. Then move up to the next prime number. You end when the residue is less than the square of the last prime number that is a factor - and that will be the last prime factor.
The prime numbers in order are 2:3:5:7:11;13:17;19:23;29…. (ad infinitem)
So take a number like 406
First prime number is 2: divide 406 by 2 and you get 203 so 2 is a factor
Divide 203 by 2 and you get a remainder so there is only one 2 as a factor
203 doesn’t divide by 3 (sum of digits is not a multiple of 3) or 5 (does not end in a 5 or 0)
203 does divide by 7 though - 29 times. So 7 is another factor.
And since 29 is less than 7^2 then that is the last prime factor.
So 406 = 2 X 7 X 29