Written by Arnold G. Reinhold, circa 1961, at the City College of New York
This code sample was re-typed in March 1997 from an original Flexowriter printout I found in my files. Lines after final "daprt" statement are, I believe, compiler output, consisting of a list of missing-labels, followed by an error code, followed by a label-to-address table.
This sample is one of my first attempts to write a computer program. I did get it running eventually. The use of arrays for this computation is unnecessary, but I was just learning.
s1'dim'a'500'm'500'q'500'' index'j'j+1'j-1'' daprt'e'n't'e'r' 'd'a't'a''cr'' rdxit's35'' s2iread'm'1''iread'q'1''iread'd''iread'n'' 1';'j'' 0'flo'd';'d.'' s3'sqrt'd.';'sqrd.'' 1'unflo'sqrd.'i/'10';'sqrd'' 2010'print'sqrd.''2000'iprt'sqrd''cr''cr'' 500'iprt'j'' ['m'1'i+'sqrd']'i/'q'1';'a'1'' a'1'ix'q'1'i-'m'1';'m'2'' s6'['d'i-'m'2'ix'm'2']'i/'q'1';'q'2'' 1000'iprt'a'1''1000'iprt'm'1''1000'iprt'q'1'' cr'' s9'j'i+'1';'j''j'i+'1';'j+1''j'i-'1';'j-1'' ['m'j'i+'sqrd']'i/'q'j';a'j'' a'j'ix'q'j'i-'m'j';'m'j+1'' q'j-1'i+'a'j'ix'['m'j'i-'m'j+1']';'q'j+1'' s15'500'iprt'j''1000'iprt'a'j''1000'iprt'm'j''1000'iprt'q'j''cr'' s19'if'['j'i-'n']'neg's20'zero's40'pos's40'' s20'if'['a'j'i-'a'2']'neg's9'zero's21'pos's9'' s21'if'['m'j'i-'m'2']'neg's9'zero's22'pos's9'' s22'if'['q'j'i-'q'2']'neg's9'zero's23'pos's9'' s23'2000'iprt'm'j+1''1000'iprt'q'j+1''cr'' daprt'p'e'r'i'o'd' 'i's'' s000 0000 s035 0341 s040 0639 s040 0641 f 0730 s001 0302 s002 0342 s003 0362 s006 0445 s009 0511 s015 0606 s019 0634 s020 0642 s021 0652 s022 0662 s023 0708
Here is my attempt 36 years later to translate the above program into BASIC. The original code is included as BASIC comment lines ("REM"). The four digit numbers in front of the print and iprt statements are format codes indicating the numger of character and the number of digits to the right of the decimal point.
REM s1'dim'a'500'm'500'q'500'' DIM A(500), M(500), Q(500) REM index'j'j+1'j-1'' REM daprt'e'n't'e'r' 'd'a't'a''cr'' PRINT "enter data" REM rdxit's35'' REM s2iread'm'1''iread'q'1''iread'd''iread'n'' READ M(1), Q(1), D, N REM 1';'j'' J=1 REM 0'flo'd';'d.'' D$=D REM s3'sqrt'd.';'sqrd.'' SQRD$=SQRT(D) REM 1'unflo'sqrd.'i/'10';'sqrd SQRD=FIX(10.0*SQRD$)/10 REM 2010'print'sqrd.''2000'iprt'sqrd''cr''cr'' PRINT SQRD$, SQRD PRINT REM 500'iprt'j'' PRINT J; REM ['m'1'i+'sqrd']'i/'q'1';'a'1'' A(1)=(M(1)+SQRD)/Q(1) REM a'1'ix'q'1'i-'m'1';'m'2'' M(2)=A(1)*q(1)-M(1) REM s6'['d'i-'m'2'ix'm'2']'i/'q'1';'q'2'' 6 Q(2)=(D(1)-m(2)*m(20)/Q(1) REM 1000'iprt'a'1''1000'iprt'm'1''1000'iprt'q'1'' REM cr'' PRINT A(1), M(1), Q(1) REM s9'j'i+'1';'j''j'i+'1';'j+1''j'i-'1';'j-1'' 9 J=J+1 JPLUS1=J+1 JMINUS1=J-1 REM ['m'j'i+'sqrd']'i/'q'j';a'j'' A(J)=(M(J)+SQRD)/Q(J) REM a'j'ix'q'j'i-'m'j';'m'j+1'' M(JPLUS1)=A(J)*Q(J)-M(J) REM q'j-1'i+'a'j'ix'['m'j'i-'m'j+1']';'q'j+1'' Q(JPLUS1)=Q(JMINUS1)+A(J)*)M(J)-M(JPLUS1) REM s15'500'iprt'j''1000'iprt'a'j''1000'iprt'm'j''1000'iprt'q'j''cr'' 15 PRINT J, A(J), M(J), Q(J) REM s19'if'['j'i-'n']'neg's20'zero's40'pos's40'' 19 IF (J-N) >= 0 GO TO 40 REM s20'if'['a'j'i-'a'2']'neg's9'zero's21'pos's9'' 20 IF (A(J) NE A(2)) GO TO 9 REM s21'if'['m'j'i-'m'2']'neg's9'zero's22'pos's9'' 21 IF (M(J) NE M(2)) GO TO 9 REM s22'if'['q'j'i-'q'2']'neg's9'zero's23'pos's9'' 22 IF (Q(J) NE Q(2)) GO TO 9 REM s23'2000'iprt'm'j+1''1000'iprt'q'j+1''cr'' 23 PRINT M(JPLUS1), Q(JPLUS1) REM daprt'p'e'r'i'o'd' 'i's'' Print "period is"