Last active
February 11, 2021 13:00
-
-
Save jdriordan/4a373e39f5a7ef1f900fc4d50b1ed20c to your computer and use it in GitHub Desktop.
Nearest-integer square root in Forth
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/gforth | |
| : sq dup * ; | |
| : is_sqrt? over sq - >= ; | |
| : sqrt 1 begin 1+ 2dup swap is_sqrt? until ; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment