HP Forums

Full Version: (35S) Fermat's Factorization Programme
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
For input of a positive composite odd number the programme returns a factor. Fermat's method seeks to find two squares differing by the input as
n= x^2-y^2=(x+y)(x-y) & hey presto, two factors have been found.

1 LBL X
2 STO A
3 SQRTx
4 IP
5 2*REGX+1►X
6 SGN
7 STO Y
8 R↓
9 x^2
10 RCL- A
11 x=0?
12 GTO X024
13 RCL+ X
14 2
15 STO+ X
16 R↓
17 RCL- Y
18 2
19 STO+ Y
20 R↓
21 x>0?
22 GTO X017
23 GTO X011
24 RCL X
25 RCL- Y
26 2
27 ÷
28 RTN
Reference URL's