>>1
That's what your assignment is about, to know how to write that in code. I'll lend you a hand, which is much better for you than if I write it.
To know if a number is prime, you could try dividing it by anything - anything it should be divided by, that is. You wouldn't divide by 0 unless you're in /sci, you won't divide by 1 because it'll always work, so you want to start with 2. And where will you end? To check for primality, you'd end in the square root of the number. For example, for 100, you'd try 2 to 10. Of course, there are divisors higher than 10, like 20, but what's 100/20? 5 - you'd catch this one earlier on anyways.
So you should take the number, and loop from 2 to the square root of that number, trying to divide the number and seeing if it can be divided. How? When you can divide A by B (integer division), A mod B (A % B) is 0.
Then onto factoring. Think of how you do it by hand.