in reply to Re^2: why is my for loop using modulo giving me a weird output
in thread why is my for loop using modulo giving me a weird output
I tried with five just to check out how modulo worked
https://en.wikipedia.org/wiki/Modulo_operation
I expected the output to look like this:
1 2 3 4
Why? Modulo is the remainder of the division. 0 divided by 5 is 0, remaining 0. 1 divided by 5 is 0, remaining 1. 2 divided by 5 is 0, remaining 2. 3 divided by 5 is 0, remaining 3. 4 divided by 5 is 0, remaining 4. 5 divided by 5 is 1, remaining 0. 6 divided by 5 is 1, remaining 1. And so on.
Alexander
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: why is my for loop using modulo giving me a weird output
by perlynewby (Scribe) on Jun 28, 2015 at 08:10 UTC | |
by marinersk (Priest) on Jun 28, 2015 at 08:50 UTC | |
by perlynewby (Scribe) on Jun 28, 2015 at 09:51 UTC | |
by ww (Archbishop) on Jun 28, 2015 at 11:35 UTC | |
by marinersk (Priest) on Jun 29, 2015 at 14:29 UTC |