I believe this is also the algorithm included in the TI-83 (plus) manual: https://www.manualowl.com/m/Texas%20Instruments/TI-83-Plus/M...
I remember sitting on the floor of our living room programming this in character by character on that TI keyboard. It's the first BASIC program I ever wrote. Everything before that was js and html.