Skip to content

Instantly share code, notes, and snippets.

@run-dlang
Created October 31, 2023 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save run-dlang/8cad219c17290b1801a993a67eded928 to your computer and use it in GitHub Desktop.
Save run-dlang/8cad219c17290b1801a993a67eded928 to your computer and use it in GitHub Desktop.
Code shared from run.dlang.io.
import std;
void main()
{
foreach (n; 1..101) {
string rules = (
(n % 3 == 0 ? "Fizz" : "") ~
(n % 5 == 0 ? "Buzz" : "")
);
"%d: %s".writefln(n, rules ? rules : n.to!string);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment