Created
April 18, 2020 10:46
-
-
Save jasongorman/eacd3b2f539be3d85bb34db85733f656 to your computer and use it in GitHub Desktop.
This file contains 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
IDENTIFICATION DIVISION. | |
PROGRAM-ID. SQRT. | |
DATA DIVISION. | |
WORKING-STORAGE SECTION. | |
01 prev PIC 9(08)V9(12) VALUE ZEROES. | |
LINKAGE SECTION. | |
01 num PIC 9(08)V9(12). | |
01 root PIC 9(08)V9(12) VALUE ZEROES. | |
PROCEDURE DIVISION USING num, root. | |
MAIN-PROCEDURE. | |
COMPUTE root = num / 2 | |
PERFORM GUESS UNTIL root = prev | |
STOP RUN. | |
GUESS. | |
MOVE root TO prev | |
COMPUTE root = (root + (num/root))/2 | |
GOBACK. | |
END PROGRAM SQRT. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment