Skip to content

Instantly share code, notes, and snippets.

@run-dlang
Created October 31, 2023 15:15
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/cdfcf11f54f78801a1515e1f14aea58a to your computer and use it in GitHub Desktop.
Save run-dlang/cdfcf11f54f78801a1515e1f14aea58a 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