Skip to content

Instantly share code, notes, and snippets.

@ronnieoverby
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ronnieoverby/dfef3d3b0f5d5167a0ea to your computer and use it in GitHub Desktop.
Save ronnieoverby/dfef3d3b0f5d5167a0ea to your computer and use it in GitHub Desktop.
FizzBuzz
/* "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()));
@bdavisjr
Copy link

nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment