Skip to content

Instantly share code, notes, and snippets.

View kothiba's full-sized avatar

tarutaru kothiba

View GitHub Profile
@kothiba
kothiba / FizzBuzz.py
Created February 12, 2017 11:10
I wrote FizzBuzz in Python
# coding: utf-8
for i in range(1,31):
if i % 15 == 0:
print 'FizzBuzz'
elif i % 3 == 0:
print 'Fizz'
elif i % 5 == 0:
print 'Buzz'
else:
print i
@kothiba
kothiba / FizzBuzz.rb
Created February 12, 2017 10:59
I wrote FizzBuzz in Ruby
for num in 1..30 do
if num % 15 == 0
puts "FizzBuzz"
elsif num % 5 == 0
puts "Buzz"
elsif num % 3 == 0
puts "Fizz"
else
puts num
end
@kothiba
kothiba / FizzBuzz.js
Created February 12, 2017 10:45
I wrote FizzBuzz in JavaScript
for (var i = 1; i <= 30; i++) {
if (i % 3 == 0 && i % 5 == 0)
console.log("Fizz,Buzz");
else if (i % 3 == 0)
console.log("Fizz");
else if (i % 5 == 0)
console.log("Buzz");
else // iが3の倍数でも5の倍数でもない
console.log(i);
}
@kothiba
kothiba / FizzBuzz.pl
Created February 12, 2017 10:32
I wrote FizzBuzz in Perl
#!/usr/bin/env perl
use strict;
use warnings;
for my $str (1..30) {
if ($str % 3 == 0 && $str % 5 ==0) {
print "fizzbuzz\n";
} elsif ($str % 3 == 0) {
print "fizz\n";
} elsif ($str % 5 == 0) {