Prime Factorization

Prime Factorization

Here are some screenshots of our prime factorization program, and that was rather hard for us (at that time, of course):

This is our code for the program. It's uploaded as a zip folder at the bottom.

As you could see (if you zoom), we input the 124 and the program gave us the primes 2, 2, and 31. And they do indeed give us 124!

How it works:

the "int[] all" created a group of numbers (integers) called "all". This group of numbers include all the numbers smaller than the numbers entered.. I made it so that there would be something to search all the prime factors from. After that, I checked if the all the numbers are divisible. If any numbers in "all" are not divisible, I put it in the "List<int> prime" by using "prime.Add(all[i])". This puts all the prime number under the input "num". Finally, I checked if the number "num" is divisible by any number in the "List<int> prime". If it does, then I print it out onto the screen, divide the number "num", and check the same number again. Voila! You have the prime factors of your number!

If you want to go back, to Background Research, click Here.