Skip to content

Commit a4c70fb

Browse files
committed
Early exit from inner loop
1 parent c11f3f3 commit a4c70fb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

progs/primes.psc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ WHILE primes > 0
1717
WHILE p * p <= n
1818
IF n MOD p = 0 THEN
1919
is_prime <- False
20+
p <- n
21+
ELSE
22+
p <- p + 1
2023
ENDIF
21-
p <- p + 1
2224
ENDWHILE
2325
IF is_prime THEN
2426
printout <- printout + INT_TO_STRING(n) + ' '

0 commit comments

Comments
 (0)