Loops/Increment loop index within loop body: Difference between revisions
Content added Content deleted
SantiagoPiM (talk | contribs) (=={{header|Common Lisp}}== Added Common Lisp) |
SantiagoPiM (talk | contribs) (→{{header|Common Lisp}}: Ups, typo with test function) |
||
Line 1,117: | Line 1,117: | ||
((= c 42)) ; Break condition when there are 42 primes |
((= c 42)) ; Break condition when there are 42 primes |
||
(incf i) ; Increments index by unity |
(incf i) ; Increments index by unity |
||
(if ( |
(if (primep i)(progn (incf c) ; If prime increment count of primes |
||
(format t "~&~5<~d~;->~>~20<~:d~>" c i) ; Display count of primes found and the prime |
|||
(incf i (decf i))))) ; Increment index to previous index plus the prime |
|||
</lang> |
</lang> |
||
{{out}} |
{{out}} |