11-29-2016, 06:16 PM
The programme accepts a positive, composite odd number from Ans in the Home screen & returns a factor in Ans.
Fermat's method involves expressing the number to factor as the difference of two different integer squares & so finding two factors.
The only division involved is in the last line of the programme.
Fermat's method involves expressing the number to factor as the difference of two different integer squares & so finding two factors.
The only division involved is in the last line of the programme.
Code:
Ans►N:
INT(√Ans)►R:
2*Ans+1►X:
1►Y:
R^2-N►R:
WHILE R
REPEAT
R+X►R:
X+2►X:
DO
R-Y►R:
Y+2►Y:
UNTIL
R≤0
END:
END:
(X-Y)/2: