Pollard’s $\rho$ with a tortoise and a rabbit: at step $i$ the tortoise is at $x_i$ and the rabbit is at $x_{2i}$, and we check $\gcd(x_{2i} - x_i, n)$. The function is currently set to $f(x) = x^2 + 1$ with $x_0 = 2$. Change $n$ to the number you want to factor; increase the loop bound if it runs out of steps.