Euclidean division is an iterative process that has been made super-efficient at the CPU level, right?
Its specification is that if I do (q, r) = f(n, d)
, I get super efficient result verifying that n = d * q + r
with maximal q
.
I need to perform a similar decomposition of an integer number, into the highest inferior triangular number and a remainder. In the same terms, this is (i, r) = g(n)
verifying that n = i * (i + 1) / 2 + r
with maximal i
.
What's the way to go? What's the fastest I can get compared to euclidean division?