Factoring: Gven an integer N, find integers 1 < a, b < N such that N = ab if they exist, otherwise say N is prime.
I know that primality testing is in P, but why not factoring?
Here is my algorithm:
For each a = 1 ... sqrt(N)
if(N % a == 0)
b = N/a
add (a,b) to the result
Endif
EndFor
This runs in O(sqrt(N)).