Acorn Computers BBC Micro Model B w/8271 — Acorn BBC Micro Model B w/8271 User Guide Manual PDF (EN)

37 480 X=Y-800 490 Y=804: D=3 500 RETURN PERSIAN This program produces a pattern by drawing hundreds of lines. Random colours are selected by lines 60 and 70. Line 80 moves the origin (middle) of the picture to the middle of the screen. 10 REM PERSIAN 20 REM ACORN COMPUTERS 30 REM VERSION 2/16 NOV 81 40 MODE 1 50 D%=4 60 VDU 19,2,RND(3)+1,0,0,0 70 VDU 19,3,RND(3)+4,0,0,0 80 VDU 29,640;400; 90 J1%=0 100 FOR K%=400 TO 280 STEP -40 110 REPEAT J2%=RND(3):

UNTIL J2% J1% 120 J1%=J2% 130 GCOL 3,J1% 140 FOR I%=-K% TO K% STEP D% 150 MOVE K%,I% 160 DRAW -K%,-I% 170 MOVE I%,-K% 180 DRAW -I%,K% 190 NEXT 200 NEXT SQR ROOT This program calculates the square root of a number by repeating a simple operation (line 90 and 200) until the calculated result stays steady. The program also indicates how long the calculation takes. This program illustrates an important mathematical technique but of course you don’t have to work out square roots this way – the function SQR is provided in BASIC (see chapter 33).

10 REM ROOT 20 REM VERSION 1.0 / 16 NOV 81 30 REM TRADITIONAL ITERATION METHOD 40 REM TO CALCULATE THE SQUARE ROOT 50 REM OF A NUMBER TO 3 DECIMAL PLACES 60 MODE 7