5 DEFINT A-Z 10 INPUT "Number:";A 15 IF A=0 THEN GOTO 50 20 GOSUB 1000 30 PRINT "Square root ";A;"=";B 40 GOTO 10 50 END 60 REM ------------------------------ 1000 REM SQUARE ROOT ROUTINE. RETURNS ROOT OF A IN 1010 REM B. WORKSPACE IS C AND D. 1020 IF A>1 GOTO 1050 1030 B = 1 1040 RETURN 1050 B = A\182 + 2 1060 D = 0 1070 C = (B + A\B)\2 1074 REM CHECK IF C SHOULD BE ROUNDED UP 1075 IF (A - A\(2*B)*B*2)>B THEN C = C + 1 1080 IF B = C THEN RETURN 1085 REM CHECK FOR OSCILLATION OF RESULT 1090 IF (B-C) = D GOTO 1130 1100 D = C-B 1110 B = C 1120 GOTO 1070 1130 REM PICK THE LARGER OF B OR C THEN RETURN 1140 IF B>C RETURN 1150 B = C 1160 RETURN