logic of NFACTOR

Can anyone please explain me the logic of this code of NFACTOR.
The link to code is Competitive_Programming/NFACTOR.cpp at master · apsc/Competitive_Programming · GitHub