Skip to content

Instantly share code, notes, and snippets.

@rigibun
Created October 29, 2013 05:15
Show Gist options
  • Save rigibun/7209463 to your computer and use it in GitHub Desktop.
Save rigibun/7209463 to your computer and use it in GitHub Desktop.
import std.stdio;
import std.conv;
string fizzbuzz(immutable ulong num)
{
return (num % 15 == 0)? "FizzBuzz": (num % 3 == 0)? "Fizz": (num % 5 == 0)? "Buzz": num.to!string();
}
string[] genfbtable(immutable ulong num)
{
string[] ret = ["0"];
for(ulong i = 1; i <= num; i++)
ret ~= fizzbuzz(i);
return ret;
}
void main()
{
immutable ulong num = 100;
static string[] table = genfbtable(num);
foreach(r, v; table)
if(r != 0)
writeln(r, ' ', v);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment