
Fermat's factorization method with GMP - Wiremask
https://wiremask.eu/articles/fermats-prime-numbers-factorization/
======
YomiK
Hart's OLF:

[http://wrap.warwick.ac.uk/54707/1/WRAP_Hart_S144678871200014...](http://wrap.warwick.ac.uk/54707/1/WRAP_Hart_S1446788712000146a.pdf)

is an interesting variant. Like Caroline mentioned, you won't have any success
with this on properly formed RSA keys, but Hart's OLF will very quickly factor
some poorly made ones, and works quite a bit better in that respect than
standard Fermat. It not only quickly finds N=P _Q where P=Q+x for a small x,
but also where P=k_ Q+x for some integer k and small x. Again not something
any proper RSA key generation method will produce, but the ways people can
screw things up is pretty high, and it might be worth giving it a few seconds
just in case.

For small values, unlike Hart I find SQUFOF to be faster, but this is
implementation specific. HOLF is also, like Fermat's method, extremely simple
to implement.

------
CarolineW
Nice article, although brief and short on some details. More something to get
you started than to actually explain anything in real detail.

It always annoys me, though, when articles like this say:

    
    
      > This code has great performances
      > and can factorize prime numbers
      > in a very short amount of time.
    

Sloppy. Unnecessarily sloppy. One is not factoring primes. Yes, I know what is
meant, but in subjects like programming, maths, and cryptography, surely one
should be more precise.

Oh, and I'm sure every reader knows that in real life you'd _never_ use this
method to factor. _Way_ too slow, and there are _many_ ways to speed it up.
Nice naive introduction, though.

