SET TALK off
DO WHIL T
ERAS
STOR 0.0000001 to D
STOR ' ' to A
STOR "Press <RETURN>." to A
STOR "NUMBER" to N
STOR "SQ:ROOT" to Q
@ 10,1 SAY ' '
INPUT "   Derive SQUARE ROOT of what number ? " to &N
ERAS
IF &N<0
@ 10,10 SAY "IMAGINARY square root."
ENDI
IF &N=0
@ 10,10 SAY "Square root of ZERO is ZERO."
ENDI
IF &N<=0 
@ 13,15 SAY A
WAIT
LOOP
ENDI
@ 10,20 SAY 'WORKING.'
STOR &N to TE
STOR 0 to E
DO WHIL TE<1
STOR TE*100 to TE
STOR 1+E to E
ENDD
STOR TE*.5 to &Q
STOR 0 to I
DO WHIL I<15
STOR TE/&Q to Z
STOR 1+I to I
IF Z*Z-TE>D .OR. TE-Z*Z>D
STOR (1.0/2)*(Z+&Q) to &Q
ELSE
STOR 15 to I
ENDI
ENDD
IF &Q-INT(&Q)<D
STOR INT(&Q) to &Q
ELSE
STOR (&Q*10000000) to &Q
STOR INT(&Q) to &Q
STOR &Q*D to &Q
ENDI
STOR 1 to F
DO WHIL E>0
STOR E-1 to E
STOR .1*F to F
ENDD
STOR &Q*F to &Q
RELE F,E,TE,I,R,D,Z,A,N,Q
ERAS
@ 10,10 SAY ' '
DISP MEMO
?
?
?"     Another SQUARE ROOT? -- Y(es) or N(o)?" 
WAIT to R
IF !(R)='Y'
LOOP
ELSE
SET TALK on
ERAS
CANC
ENDI	
ENDD
