--- title: "Return on Investment" id: 76586 type: "computer_media" slug: "return-on-investment" url: "http://localhost/computer_media/return-on-investment/" markdown_url: "http://localhost/computer_media/return-on-investment.md" published_at: "2026-11-11T08:02:25+00:00" modified_at: "2026-11-11T08:02:25+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2026/11/return-on-investment-1.png" excerpt: "Find the compound annual rate of return on up to 20 single investments and four monthly investments, made at different dates." post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "TS 1000" slug: "ts1000" taxonomy: "post_tag" url: "http://localhost/tag/ts1000/" - name: "ZX81" slug: "zx81" taxonomy: "post_tag" url: "http://localhost/tag/zx81/" model: - name: "Sinclair ZX81" slug: "zx81" taxonomy: "model" url: "http://localhost/model/zx81/" - name: "Timex/Sinclair 1000" slug: "ts-1000" taxonomy: "model" url: "http://localhost/model/ts-1000/" indiv: - name: "Russell Crum" slug: "russell-crum" taxonomy: "indiv" url: "http://localhost/indiv/russell-crum/" genre: - name: "Finance" slug: "finance" taxonomy: "genre" url: "http://localhost/type/finance/" media_type: "Program" programmers: - name: "Russell Crum" slug: "russell-crum" taxonomy: "indiv" url: "http://localhost/indiv/russell-crum/" download_url: "https://archive.org/download/timex-sinclair-software-archive/Return%20on%20Investment%20%281983%29%28Crum%2C%20Russell%29%28TS1000%29%28US%29%28Program%29.zip" mediadate: "1983" images: - url: "http://localhost/wp-content/uploads/2026/11/return-on-investment-1.png" - url: "http://localhost/wp-content/uploads/2026/11/return-on-investment-2.png" article_media: - id: 19533 title: "Return on Investment" type: "article" url: "http://localhost/article/return-on-investment/" media_type_tags: "Finance" license: false --- # Return on Investment Works out the rate of return on a set of investments by trial and error. Answer N to the first question, then enter each single investment’s month, day, year and amount, and 0 for the month to finish; then up to four monthly investments the same way. Give the current date and the current value of the investments, and the program tries one rate after another until the calculated value is within 0.1 percent of the real one, then prints the rate of return and the remaining balance. It counts the exact number of days between dates, so a run can take a while. You can save the program with its data and later run it again with a new current value. The article explains how to allow more investments and how to tighten the accuracy in line 690. The rate must be at least 1 percent, and the program handles only gains, not losses. Published in Syntax August 1983 ([Return on Investment](https://timexsinclair.com/article/return-on-investment/)). ## Source Code ``` 10 REM RETURN ON INVESTMENT 20 REM R.CRUM MAY 8,1983 30 DIM N(12) 40 LET N(1)=0 50 LET N(2)=31 60 LET N(3)=59 70 LET N(4)=90 80 LET N(5)=120 90 LET N(6)=151 100 LET N(7)=181 110 LET N(8)=212 120 LET N(9)=243 130 LET N(10)=273 140 LET N(11)=304 150 LET N(12)=334 160 GOTO 1070 170 LET Y=0 171 LET FLAG1=0 172 LET FLAG2=0 180 FAST 190 GOTO 260 200 REM SINGLE SUM VALUE 210 LET Z=L*(1+A)**K 220 RETURN 230 REM ANNUITY VALUE 240 LET Z=L*(((1+A)**K-1)/A) 250 RETURN 260 REM SINGLE INVESTMENTS 270 IF B=0 THEN GOTO 480 280 FOR I=1 TO B 290 LET K=0 300 FOR X=A(I,3) TO C(3)-1 310 LET K=K+365 320 IF INT (X/100)*100=X AND INT (X/400)*4002 THEN LET K=K-1 380 IF INT (C(3)/100)*100=C(3) AND INT (C(3)/400)*4002 THEN LET K=K+1 400 LET K=K-N(A(I,1))-A(I,2) 410 LET K=K+N(C(1))+C(2) 420 IF A(I,3)=C(3) THEN LET K=K-365 430 LET L=A(I,4) 440 GOSUB 200 450 LET Y=Y+Z 460 NEXT I 470 REM ANNUITY INVESTMENTS 480 IF C=0 THEN GOTO 680 490 FOR I=1 TO C 500 LET K=0 510 FOR X=B(I,3) TO C(3)-1 520 LET K=K+365 530 IF INT (X/100)*100=X AND INT (X/400)*4002 THEN LET K=K-1 590 IF INT (C(3)/100)*100=C(3) AND INT (C(3)/400)*4002 THEN LET K=K+1 610 LET K=K-N(B(I,1))-B(I,2) 620 LET K=K+N(C(1))+C(2) 630 IF B(I,3)=C(3) THEN LET K=K-365 640 LET L=B(I,4) 650 GOSUB 230 660 LET Y=Y+Z 670 NEXT I 680 REM CHECK BALANCE 690 IF ABS (C(4)-Y)Y))+((A-A/2) AND (C(4)=A/2))+(A/2 AND (A+A*((C(4)-Y)/C(4))LEN A$ THEN GOTO 1160 1150 NEXT I 1160 PRINT A$((I+1) TO ) 1170 PRINT 1180 PRINT "PRESS ""CONT"" TO CONTINUE" 1190 PAUSE 4E4 1200 CLS 1210 PRINT "WANT TO RE-EVALUATE LOADED DATA?(Y OR N)" 1220 INPUT R$ 1230 IF R$="Y" THEN GOTO 1750 1240 DIM A(20,4) 1250 DIM B(4,4) 1260 DIM C(4) 1270 LET B=0 1280 LET C=0 1290 LET A(1,3)=3000 1300 LET B(1,3)=3000 1310 REM INPUT 1320 FOR I=1 TO 20 1330 CLS 1340 PRINT "SINGLE INVEST NO. ";I 1350 PRINT "MONTH? (2 DIGITS)" 1360 INPUT A(I,1) 1370 PRINT A(I,1) 1380 IF A(I,1)=0 THEN GOTO 1530 1390 PRINT "SINGLE INVEST NO. ";I 1400 PRINT " DAY?(2 DIGITS)" 1410 INPUT A(I,2) 1420 PRINT A(I,2) 1430 PRINT "SINGLE INVEST NO. ";I 1440 PRINT " YEAR?(4 DIGITS)" 1450 INPUT A(I,3) 1460 PRINT A(I,3) 1470 PRINT "SINGLE INVEST NO ";I;" AMOUNT" 1480 INPUT A(I,4) 1490 PRINT A(I,4) 1500 PAUSE 200 1510 LET B=I 1520 NEXT I 1530 FOR I=1 TO 4 1540 CLS 1550 PRINT "MO. INV. NO.";I 1560 PRINT " MONTH BEGIN (2 DIGITS)" 1570 INPUT B(I,1) 1580 PRINT B(I,1) 1590 IF B(I,1)=0 THEN GOTO 1750 1600 PRINT "MO. INV. NO.";I 1610 PRINT "DAY?(2 DIGITS)" 1620 INPUT B(I,2) 1630 PRINT B(I,2) 1640 PRINT "MO. INV. NO.";I 1650 PRINT " YEAR BEGIN (4 DIGITS)" 1660 INPUT B(I,3) 1670 PRINT B(I,3) 1680 PRINT "MO. INV. NO. ";I;" AMT" 1690 INPUT B(I,4) 1700 PRINT B(I,4) 1710 LET B(I,4)=(B(I,4)*12)/365 1720 PAUSE 200 1730 LET C=I 1740 NEXT I 1750 CLS 1760 PRINT "CURRENT MONTH?(2 DIGITS)" 1770 INPUT C(1) 1780 PRINT C(1) 1790 PRINT "CURRENT DAY?(2 DIGITS)" 1800 INPUT C(2) 1810 PRINT C(2) 1820 PRINT "CURRENT YEAR?(4 DIGITS)" 1830 INPUT C(3) 1840 PRINT C(3) 1850 PRINT "CURRENT VALUE OF INVESTMENTS?" 1860 INPUT C(4) 1870 PRINT C(4) 1880 LET A=.000263 1890 PAUSE 200 1900 CLS 1910 GOTO 170 ```