Loops/Increment loop index within loop body: Difference between revisions
Content added Content deleted
Line 1,540:
Haxe's for-loop does allow the index to be modified in the body of the loop, so a while-loop is used instead.
<lang haxe>using StringTools;
import haxe.Int64;
class PrimeNumberLoops {
private static var limit = 42;
static function isPrime(i:
if (i == 2 || i == 3) {
return true;
Line 1,561 ⟶ 1,562:
static function main() {
var i:
var n:
while (n < limit) {
if (isPrime(i)) {
n++;
Sys.println('n ${
'= ${
i += i;
continue;
|