Made the FermatFactor function recursive