Post Reply 
(12C) Finding Two Factors Close to N
10-20-2019, 11:02 PM
Post: #2
RE: (12C) Finding Two Factors Close to N
(10-20-2019 03:10 PM)Eddie W. Shore Wrote:  N = (B - A) * (B + A)

The program tests every integer higher than √N. Let B = int(√N) + 1. If A = N - B^2 is an integer, the search stops.

I think you meant the program test integer C = A+B, A+B+1, A+B+2, ...
If C^2 - N is a square, then stop

Using your example, N = 22356

C = int(√N) + 1 = 150
C^2 - N = 144 = 12^2

→ N = 150^2 - 12^2 = (150 + 12) * (150 - 12) = 162 * 138

Thomas Kleem also posted Fermat Factorization code for HP-12C, but only for odd N
https://www.hpmuseum.org/forum/thread-11...#pid103729
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (12C) Finding Two Factors Close to N - Albert Chan - 10-20-2019 11:02 PM



User(s) browsing this thread: 1 Guest(s)