Stdle #6 · 2026-06-12
A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
1const std = @import("std");2pub fn main() void {3 const n: i32 = -7;4 std.debug.print("{d} {d}\n", .{ @mod(n, 3), @rem(n, 3) });5}
Console output
Why
`@mod` follows the sign of the divisor (always non-negative for a positive divisor), so `@mod(-7, 3)` is 2. `@rem` follows the sign of the dividend, so `@rem(-7, 3)` is -1. They satisfy `@divFloor`+`@mod` and `@divTrunc`+`@rem` respectively.