Changed largestFactor function to factor function.