Primality by trial division: Difference between revisions

Content deleted Content added
→‎{{header|ZX Spectrum Basic}}: Added implementation as a sub-type of BASIC.
→‎{{header|ZX Spectrum Basic}}: - Do not jump out of a loop on the ZX Spectrum - Unterminated loops use stack space
Line 124: Line 124:
1010 LET p=0
1010 LET p=0
1020 IF n/2=INT (n/2) THEN RETURN
1020 IF n/2=INT (n/2) THEN RETURN
1030 FOR i=3 TO SQR (n) STEP 2
1030 LET p=1
1040 IF n/i=INT (n/i) THEN RETURN
1040 FOR i=3 TO SQR (n) STEP 2
1050 IF n/i=INT (n/i) THEN LET p=0: LET i= SQR (n)
1050 NEXT i
1060 LET p=1: RETURN
1060 NEXT i
1070 RETURN
</lang>
</lang>
Output:
Output: