Skip to content

Instantly share code, notes, and snippets.

@shtaxxx
Created October 24, 2013 08:38
Show Gist options
  • Save shtaxxx/7133396 to your computer and use it in GitHub Desktop.
Save shtaxxx/7133396 to your computer and use it in GitHub Desktop.
FizzBuzz
#1.upto(?d){|i|puts"#{i%3<1?'Fizz':i%5>0?i:''}#{'Buzz'if i%5<1}"}
#1.upto(?d){|i|puts [[:Fizz][i%3],[:Buzz][i%5]]*''}
#1.upto(?d){|i|i%3<1&&x=:Fizz;puts i%5<1?"#{x}Buzz":x||i}
#1.upto(?d){|i|puts [i%3<1?:Fizz:i%5>0?i:'',[:Buzz][i%5]]*''}
#?d.times{|i|puts [i%3<1?:Fizz:i%5>0?i:'',[:Buzz][i%5]]*''}
100.times{|i|i%3<1&&x=:Fizz;puts i%5<1?"#{x}Buzz":x||i}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment