Binary search: Difference between revisions

→‎{{header|Minimal BASIC}}: Corrected. Minimal BASIC does not have the operators OR, AND, NOT.
m (Automated syntax highlighting fixup (second round - minor fixes))
(→‎{{header|Minimal BASIC}}: Corrected. Minimal BASIC does not have the operators OR, AND, NOT.)
Line 1,608:
{{works with|Commodore BASIC|3.5}}
{{works with|Nascom ROM BASIC|4.7}}
<syntaxhighlight lang="gwbasicbasic">
10 REM Binary search
20 LET N = 10
Line 1,640:
520 LET F = 0
530 LET M = L
540 IF L > H OR F <> 0 THEN 640650
550 LETIF MF =<> L+INT((H-L)/2)0 THEN 650
560 IFLET A(M) >= X THEN 590L+INT((H-L)/2)
570 LETIF LA(M) >= M+1X THEN 600
580 GOTOLET 540L = M+1
590 GOTO 540
590 IF A(M) <= X THEN 620
600 LETIF HA(M) <= M-1X THEN 630
610 GOTOLET 540H = M-1
620 LETGOTO F = 1540
630 GOTOLET 540F = 1
640 IFGOTO F = 0 THEN 670540
650 LETIF I1F = M0 THEN 680
660 RETURNLET I1 = M
670 LET I1 = -1RETURN
680 RETURNLET I1 = -1
690 RETURN
</syntaxhighlight>
 
=={{header|BASIC256}}==
====Recursive Solution====
512

edits