75.
Write a sub program to display first 20 prime numbers.
DECLARE SUB PRIME ( )
CLS
CALL PRIME
END
SUB PRIME
N = 1
CNT = 1
TOP:
C = 0
FOR I = 1 TO N
IF N MOD I = 0 THEN C = C +
1
NEXT I
IF C = 2 THEN
PRINT N,
CNT = CNT + 1
END IF
N = N + 1
IF CNT <= 20 THEN GOTO
TOP
END SUB
No comments:
Post a Comment