Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Even or od
- pierrepelzer
- Scratcher
100+ posts
Even or od
How can I make a program to find out whether a number is even or od.
Scratching just for fun and to keep my brains busy.
say [Happy scratching]
- awesome-llama
- Scratcher
1000+ posts
Even or od
Use modulo operation.
If a number is divided by 2, the remainder can either be 0 or 1. It would be 0 if it were even (divisible by 2), and 1 if odd.
So, in scratchblocks, it would be like this:
(() mod ()) // outputs the remainder of the quotient
If a number is divided by 2, the remainder can either be 0 or 1. It would be 0 if it were even (divisible by 2), and 1 if odd.
So, in scratchblocks, it would be like this:
if <((input number) mod (2)) = [0]> then
... // even number
else
... // odd number
end
- pierrepelzer
- Scratcher
100+ posts
Even or od
Thanks.
I didn't know what the mod-block means. Now I do.
I didn't know what the mod-block means. Now I do.
Scratching just for fun and to keep my brains busy.
say [Happy scratching]
- Discussion Forums
- » Help with Scripts
- » Even or od