Created
          October 29, 2013 05:15 
        
      - 
      
- 
        Save rigibun/7209463 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); | |
| 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