#364. Even or odd?
When the green flag is clicked, this script runs. What will the cat say?
when green flag clicked set [x v] to (205) if <((x) mod (2)) = (0)> then say [Even] else say [Odd] end
# When the green flag is clicked
x = 205
if (x % 2) == 0:
print("Even")
else:
print("Odd")
// Scratch's mod gives a positive remainder even for negative numbers
function mod(a, b) {
return ((a % b) + b) % b;
}
let x = 0;
// When the green flag is clicked
x = 205;
if ((mod(x, 2)) === 0) {
console.log("Even");
} else {
console.log("Odd");
}
💡 Not sure? Build it in Scratch and try it out.