Skip to content

Instantly share code, notes, and snippets.

@yudapc
Last active July 29, 2016 07:41
Show Gist options
  • Save yudapc/ba8354ae8d997afe21eb to your computer and use it in GitHub Desktop.
Save yudapc/ba8354ae8d997afe21eb to your computer and use it in GitHub Desktop.
fizzbuzz code
<?php
for($i = 1; $i <= 100; $i++) {
$val = $i;
if($i % 3 == 0) $val = "Fizz";
if($i % 5 == 0) $val = "Buzz";
if($i % 3 == 0 && $i % 5 == 0) $val = "FizzBuzz";
echo $val."\n";
}
puts (1..100).map{|m|a=m%3==0;p=m%5==0;(a||p)?((a)?%?Fizz?:%::)+((p)?%?Buzz?:%::):m}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment