Created
          October 29, 2013 05:15 
        
      - 
      
- 
        Save rigibun/7209458 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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) ~ '"'; | |
| ret ~= i == num ? "]" : ","; | |
| } | |
| return ret; | |
| } | |
| void main() | |
| { | |
| immutable ulong num = 100; | |
| string[] table = mixin(genfbtable(num)); | |
| for(ulong i = 1; i <= num; i++) | |
| writeln(i, " ", table[i]); | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment