Skip to content

Instantly share code, notes, and snippets.

@andrewrk
Last active August 9, 2022 02:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewrk/6780fa252b693169897686e907c9da2a to your computer and use it in GitHub Desktop.
Save andrewrk/6780fa252b693169897686e907c9da2a to your computer and use it in GitHub Desktop.
fizzbuzz in zig
const std = @import("std");
pub fn main() void {
var i: usize = 1;
while (i <= 100) : (i += 1) {
if (i % 3 == 0 and i % 5 == 0) {
std.debug.warn("FizzBuzz\n");
} else if (i % 3 == 0) {
std.debug.warn("Fizz\n");
} else if (i % 5 == 0) {
std.debug.warn("Buzz\n");
} else {
std.debug.warn("{}\n", i);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment