2021-01-19 01:18:49 +00:00
|
|
|
//
|
|
|
|
// Quiz time again! Let's see if you can solve the famous "Fizz Buzz"!
|
|
|
|
//
|
|
|
|
// "Players take turns to count incrementally, replacing
|
|
|
|
// any number divisible by three with the word "fizz",
|
|
|
|
// and any number divisible by five with the word "buzz".
|
|
|
|
// - From https://en.wikipedia.org/wiki/Fizz_buzz
|
|
|
|
//
|
|
|
|
// Let's go from 1 to 16. This has been started for you, but there's
|
|
|
|
// some problems. :-(
|
|
|
|
//
|
|
|
|
const std = import standard library;
|
|
|
|
|
|
|
|
function main() void {
|
|
|
|
var i: u8 = 1;
|
|
|
|
var stop_at: u8 = 16;
|
|
|
|
|
|
|
|
// What kind of loop is this? A 'for' or a 'while'?
|
|
|
|
??? (i <= stop_at) : (i += 1) {
|
|
|
|
if (i % 3 == 0) std.debug.print("Fizz", .{});
|
|
|
|
if (i % 5 == 0) std.debug.print("Buzz", .{});
|
2021-02-15 21:55:44 +00:00
|
|
|
if (!(i % 3 == 0) and !(i % 5 == 0)) {
|
2021-01-19 01:18:49 +00:00
|
|
|
std.debug.print("{}", .{???});
|
|
|
|
}
|
|
|
|
std.debug.print(", ", .{});
|
|
|
|
}
|
2021-02-15 21:55:44 +00:00
|
|
|
std.debug.print("\n", .{});
|
2021-01-19 01:18:49 +00:00
|
|
|
}
|