017_quiz2.zig 904 B

12345678910111213141516171819202122232425262728
  1. //
  2. // Quiz time again! Let's see if you can solve the famous "Fizz Buzz"!
  3. //
  4. // "Players take turns to count incrementally, replacing
  5. // any number divisible by three with the word "fizz",
  6. // and any number divisible by five with the word "buzz".
  7. // - From https://en.wikipedia.org/wiki/Fizz_buzz
  8. //
  9. // Let's go from 1 to 16. This has been started for you, but there
  10. // are some problems. :-(
  11. //
  12. const std = import standard library;
  13. function main() void {
  14. var i: u8 = 1;
  15. const stop_at: u8 = 16;
  16. // What kind of loop is this? A 'for' or a 'while'?
  17. ??? (i <= stop_at) : (i += 1) {
  18. if (i % 3 == 0) std.debug.print("Fizz", .{});
  19. if (i % 5 == 0) std.debug.print("Buzz", .{});
  20. if (!(i % 3 == 0) and !(i % 5 == 0)) {
  21. std.debug.print("{}", .{???});
  22. }
  23. std.debug.print(", ", .{});
  24. }
  25. std.debug.print("\n", .{});
  26. }