|
codepad
|
|
#include <stdio.h>
int main(void){
int i=0;
for(i=1;i<=100;i++){
if(i%15==0){
printf("FizzBuzz\n");
}
else if(i%5==0){
printf("Buzz\n");
}
else if(i%3==0){
printf("Fizz\n");
}
else
printf("%i\n",i);
}
return 0;
}
|
| view (21 lines, 100 lines of output) |
#include<stdio.h>
int main()
{
int i,j,k;
for(i=1;i<=100;i++)
{
if((i%3==0)&&(i%5==0))
printf("FizzBuzz\n");
else if(i%3==0)
printf("Fizz\n");
else if(i%5==0)
printf("Buzz\n");
else
printf("%d\n",i);
}
return 0;
}
|
| view (19 lines, 100 lines of output) |
#include <iostream>
int main(int argc, char* argv[])
{
// Print number s from 1 to 100
for(int i=1; i<101; ++i) {
if(i % 3 ==0) {
std::cout << "Fizz";
if(i % 5 == 0)
std::cout << "Buzz";
}
else if(i % 5 ==0)
std::cout << "Buzz";
else
std::cout << i;
std::cout << std::endl;
}
}
|
| view (23 lines, 100 lines of output) |
#include <iostream>
int main(int argc, char* argv[])
{
// Print number s from 1 to 100
for(int i=1; i<101; ++i) {
if(i % 3 ==0) {
std::cout << "Fizz";
if(i % 5 == 0)
std::cout << "Buzz";
}
else if(i % 5 ==0)
std::cout << "Buzz";
else
std::cout << i;
std::cout << std::endl;
}
}
|
| view (23 lines, 100 lines of output) |
import std.stdio;
void main()
{
for (int i = 1; i <= 100; i++) {
bool special = false;
if (i % 3 == 0) {
special = true;
writef("Fizz");
}
if (i % 5 == 0) {
special = true;
writef("Buzz");
}
if (!special) writef("%d", i);
writef("\n");
}
}
|
| view (18 lines, 100 lines of output) |
import Control.Monad.Writer
fb = const "fizzbuzz"
f = const "fizz"
b = const "buzz"
s :: Show b => b -> String
s = show
fns :: Show b => [b -> String]
fns = [fb, s, s, f, s, b, f, s, s, f, b, s, f, s, s]
main = mapM_ (putStrLn . ((fns !!) =<< (`mod` 15))) [1..100]
|
| view (12 lines, 100 lines of output) |
import Control.Monad.Writer
fb = const "fizzbuzz"
f = const "fizz"
b = const "buzz"
s x = show x--s = show
fns :: Show b => [b -> String]
fns = [fb, s, s, f, s, b, f, s, s, f, b, s, f, s, s]
main = mapM_ (putStrLn . ((fns !!) =<< (`mod` 15))) [1..100]
|
| view (11 lines, 100 lines of output) |
for i=1,100 do print(i%15==0 and"FizzBuzz"or(i%5==0 and"Buzz"or(i%3==0 and"Fizz"or i)))end
|
| view (1 line, 100 lines of output) |
--[[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”.]]
for i = 1,100 do
normal = true
if i % 3 == 0 then
io.write("Fizz")
normal = false
end
if i % 5 == 0 then
io.write("Buzz")
normal = false
end
if normal then
io.write(i)
end
io.write("\n")
end
|
| view (17 lines, 100 lines of output) |
<?php
$flag = 0;
for($count = 1; $count <= 100; $count++)
{
if($count%3 == 0){$flag = 1;echo "Fizz";}
if($count%5 == 0){$flag = 1;echo "Buzz";}
if(!$flag){echo $count;}
echo "\n";
$flag = 0;
}
?>
|
| view (11 lines, 100 lines of output) |
<?php
for($count = 1; $count <= 100; $count++)
{
if($count%3 == 0 && $count%5 == 0){echo "FizzBuzz\n";}
else if($count%3 == 0){echo "Fizz\n";}
else if($count%5 == 0){echo "Buzz\n";}
else{echo $count."\n";}
}
?>
|
| view (9 lines, 100 lines of output) |
$i=1;while($i<=100){print($i%3 eq 0 && $i%5 eq 0?fizzbuzz:($i%3 eq 0?fizz:($i%5 eq 0?buzz:$i)),"\n");$i++}
|
| view (1 line, 100 lines of output) |
$i=1;while($i<=100){if($i%3 eq 0 && $i%5 eq 0){print"fizzbuzz\n";}elsif($i%3 eq 0){print"fizz\n";}elsif($i%5 eq 0){print"buzz\n";}else{print($i,"\n");}$i++;}
|
| view (1 line, 100 lines of output) |
print '\n'.join(['Fizz'*(not i%3) + 'Buzz'*(not i%5) or str(i) for i in range(1, 101)])
|
| view (1 line, 100 lines of output) |
print '\n'.join(['Fizz'*(not i%3) + 'Buzz'*(not i%5) or str(i) for i in range(1, 101)])
|
| view (1 line, 100 lines of output) |
1.upto(100) { |x|
print "fizz" if x % 3 == 0
print "buzz" if x % 5 == 0
print x unless (x % 3 == 0) or (x % 5 == 0)
puts ""
}
|
| view (6 lines, 100 lines of output) |
1.upto(100) do |n|
if n % 3 == 0 && n % 5 == 0
puts "FizzBuzz"
elsif n % 3 == 0
puts "Fizz"
elsif n % 5 == 0
puts "Buzz"
else
puts n
end
end
|
| view (11 lines, 100 lines of output) |
(do ((i 1 (+ i 1)))
((> i 100))
(display
(cond ((= 0 (modulo i 15)) "FizzBuzz")
((= 0 (modulo i 3)) "Fizz")
((= 0 (modulo i 5)) "Buzz")
(else i)))
(newline))
|
| view (8 lines, 100 lines of output) |