About Fermat’s Integer Factoring algorithm

An implementation of Fermat’s algorithm that is a slight improvement on code in this book is here. FermatFactor[n_?OddQ]:=Module[{s=Floor@Sqrt[n+0“1],r,u,v=1}, If[s^2==n,Return@{s,s}]; {r,u}={(s+1)^2-n,2*s+3}; While[r!=0, While[r>0, r-=v;v+=2 ]; If[r<0,r+=u;u+=2] ]; (u+{-v,v-2})/2 ] The main…