Last active
August 29, 2015 14:06
-
-
Save ronnieoverby/dfef3d3b0f5d5167a0ea to your computer and use it in GitHub Desktop.
FizzBuzz
This file contains 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
/* "Write a program that prints the numbers from 1 to 100. | |
But for multiples of three print “Fizz” instead of the number | |
and for the multiples of five print “Buzz”. | |
For numbers which are multiples of both three and five print “FizzBuzz”." */ | |
Console.Write(string.Join(Environment.NewLine, | |
from n in Enumerable.Range(1, 100) | |
let m3 = n % 3 == 0 ? "Fizz" : "" | |
let m5 = n % 5 == 0 ? "Buzz" : "" | |
let s = m3 + m5 | |
select s.Any() ? s : n.ToString())); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice