+ 5
Why this source code only display odd natural numbers in Bash scripting?
Why this source code only display odd natural numbers in Bash scripting? for x in {1..99..2}; do echo $x; done there's no modulus syntax.
3 Respuestas
+ 3
in python :
for x in (1:99:2):
print x
means (start : end : step)
step means the amount of icrecement you can say...ex (1:99:2) will go
1
3
5
7
9
etc
if (1:99:3) it will go like this:
1
4
7
10
13
etc..
and so on....
+ 4
I guess the '2' says how to count in this numberseries. So it will be the distance, e.g. 1,3,5...
Try {1..99..1} to get every natural number between 1 and 99. :)
+ 2
it is like following in js.
for (var i = 1; i <= 99; i+=2)
{
document.write(i);
}