I'm currently inclined to change it to error on 0, print a leading -1 for negatives, and leave the rest alone...
-1 isn't a prime factor. "Unless it is." I'll let this speak for itself as to the can of worms opened by introducing x<1 as input without having factor.6 contain a lesson in number fields. Please, please keep input in N.