DefconDotNet

Untitled

Sep 17th, 2013
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace FizzBuzz
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             var matchers = new[]
  11.                 {
  12.                     new Tuple<int, string>(3, "Fizz"),
  13.                     new Tuple<int, string>(5, "Buzz"),
  14.                 };
  15.  
  16.             for (var i = 1; i <= 100; i++) {
  17.                 var matches = matchers.Where(c => i % c.Item1 == 0).ToList();
  18.                 if (matches.Any())
  19.                     foreach (var comb in matches)
  20.                         Console.Write(comb.Item2);
  21.                 else
  22.                     Console.Write(i);
  23.                 Console.Write(Environment.NewLine);
  24.             }
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment