logic of NFACTOR

Can anyone please explain me the logic of this code of NFACTOR.
The link to code is https://github.com/apsc/Competitive_Programming/blob/master/NFACTOR.cpp

//