Looks right to me, though I wound up reformatting the loop a little. That’s most likely a result of me being in the habit of using for loops for everything, and forgetting the proper formatting for other kinds, rather than being an actual flaw in the code—I’m willing to give bogus the benefit of the doubt about it, in any case.
Pretty much. Both you and bogus apparently forget to put an initial value into var (unless your language of choice automatically initializes them as 0).
Using while(1) with a conditional return is a little bizarre, when you can just go while(var<100).
Of course, my own draft used
if(var % 3 == 0 && var % 5 == 0)
instead of the more reasonable x%15.
Pretty much. Both you and bogus apparently forget to put an initial value into var (unless your language of choice automatically initializes them as 0).
Mine does, but I’m aware that it’s good coding practice to specify anyway. I was maintaining his choice.
Using while(1) with a conditional return is a little bizarre, when you can just go while(var<100).
Yep, but I don’t remember how else to signify an intrinsically infinite loop, and bogus’ code seems to use an explicit return (which I wanted to keep for accuracy’s sake) rather than checking the variable as part of the loop.
My method of choice would be for(var=0; var<100; ++var){} (using LSL format), which skips both explicitly returning and explicitly incrementing the variable.
integer var
while(1)
{
++var
if (var % 15 == 0)
else if (var % 3 == 0)
else if (var % 5 ==0)
else
if !(var<100)
}
Looks right to me, though I wound up reformatting the loop a little. That’s most likely a result of me being in the habit of using for loops for everything, and forgetting the proper formatting for other kinds, rather than being an actual flaw in the code—I’m willing to give bogus the benefit of the doubt about it, in any case.
Pretty much. Both you and bogus apparently forget to put an initial value into var (unless your language of choice automatically initializes them as 0).
Using while(1) with a conditional return is a little bizarre, when you can just go while(var<100).
Of course, my own draft used if(var % 3 == 0 && var % 5 == 0) instead of the more reasonable x%15.
Mine does, but I’m aware that it’s good coding practice to specify anyway. I was maintaining his choice.
Yep, but I don’t remember how else to signify an intrinsically infinite loop, and bogus’ code seems to use an explicit return (which I wanted to keep for accuracy’s sake) rather than checking the variable as part of the loop.
My method of choice would be for(var=0; var<100; ++var){} (using LSL format), which skips both explicitly returning and explicitly incrementing the variable.