langs a-z

This commit is contained in:
Ingy döt Net 2013-04-10 22:43:41 -07:00
parent db842d013d
commit d066446780
11389 changed files with 98361 additions and 1020 deletions

View file

@ -0,0 +1,19 @@
using System;
using System.Console;
module FizzBuzz
{
FizzBuzz(x : int) : string
{
|x when x % 15 == 0 => "FizzBuzz"
|x when x % 5 == 0 => "Buzz"
|x when x % 3 == 0 => "Fizz"
|_ => $"$x"
}
Main() : void
{
foreach (i in [1 .. 100])
WriteLine($"$(FizzBuzz(i))")
}
}

View file

@ -0,0 +1,8 @@
loop j=1 for 100
select
when j//15==0 then say 'FizzBuzz'
when j//5==0 then say 'Buzz'
when j//3==0 then say 'Fizz'
otherwise say j.right(4)
end
end

View file

@ -0,0 +1,12 @@
/* Fizzbuzz in nickle */
void function fizzbuzz(size) {
for (int i = 1; i < size; 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); }
}
}
fizzbuzz(1000);

View file

@ -0,0 +1,9 @@
for i in 1..100:
if i mod 15 == 0:
echo("FizzBuzz")
elif i mod 3 == 0:
echo("Fizz")
elif i mod 5 == 0:
echo("Buzz")
else:
echo(i)

View file

@ -0,0 +1,6 @@
var messages = @["", "Fizz", "Buzz", "FizzBuzz"]
var acc = 810092048
for i in 1..100:
var c = acc and 3
echo(if c == 0: $i else: messages[c])
acc = acc shr 2 or c shl 28

View file

@ -0,0 +1,9 @@
let output x =
match x mod 3 = 0, x mod 5 = 0 with
true, true -> "FizzBuzz"
| true, false -> "Fizz"
| false, true -> "Buzz"
| false, false -> string_of_int x
let _ =
for i = 1 to 100 do print_endline (output i) done

View file

@ -0,0 +1,24 @@
fizz: func (n: Int) -> Bool {
if(n % 3 == 0) {
printf("Fizz")
return true
}
return false
}
buzz: func (n: Int) -> Bool {
if(n % 5 == 0) {
printf("Buzz")
return true
}
return false
}
main: func {
for(n in 1..100) {
fizz:= fizz(n)
buzz:= buzz(n)
fizz || buzz || printf("%d", n)
println()
}
}

View file

@ -0,0 +1,23 @@
MODULE FizzBuzz;
IMPORT Out;
VAR i: INTEGER;
BEGIN
FOR i := 1 TO 100 DO
IF i MOD 15 = 0 THEN
Out.String("FizzBuzz");
Out.Ln;
ELSIF i MOD 5 = 0 THEN
Out.String("Buzz");
Out.Ln;
ELSIF i MOD 3 = 0 THEN
Out.String("Fizz");
Out.Ln;
ELSE
Out.Int(i,0);
Out.Ln;
END;
END;
END FizzBuzz.

View file

@ -0,0 +1,20 @@
bundle Default {
class Fizz {
function : Main(args : String[]) ~ Nil {
for(i := 0; i <= 100; i += 1;) {
if(i % 15 = 0) {
"FizzBuzz"->PrintLine();
}
else if(i % 3 = 0) {
"Fizz"->PrintLine();
}
else if(i % 5 = 0) {
"Buzz"->PrintLine();
}
else {
i->PrintLine();
};
};
}
}
}

View file

@ -0,0 +1,16 @@
// FizzBuzz in Objective-C
#import <stdio.h>
main() {
for (int i=1; i<=100; i++) {
if (i % 15 == 0) {
printf("FizzBuzz\n");
} else if (i % 3 == 0) {
printf("Fizz\n");
} else if (i % 5 == 0) {
printf("Buzz\n");
} else {
printf("%i\n", i);
}
}
}

View file

@ -0,0 +1,11 @@
for i = 1:100
if ( mod(i,15) == 0 )
disp("FizzBuzz");
elseif ( mod(i, 3) == 0 )
disp("Fizz")
elseif ( mod(i, 5) == 0 )
disp("Buzz")
else
disp(i)
endif
endfor

View file

@ -0,0 +1,19 @@
#include <order/interpreter.h>
// Get FB for one number
#define ORDER_PP_DEF_8fizzbuzz ORDER_PP_FN( \
8fn(8N, \
8let((8F, 8fn(8N, 8G, \
8is_0(8remainder(8N, 8G)))), \
8cond((8ap(8F, 8N, 15), 8quote(fizzbuzz)) \
(8ap(8F, 8N, 3), 8quote(fizz)) \
(8ap(8F, 8N, 5), 8quote(buzz)) \
(8else, 8N)))) )
// Print E followed by a comma (composable, 8print is not a function)
#define ORDER_PP_DEF_8print_el ORDER_PP_FN( \
8fn(8E, 8print(8E 8comma)) )
ORDER_PP( // foreach instead of map, to print but return nothing
8seq_for_each(8compose(8print_el, 8fizzbuzz), 8seq_iota(1, 100))
)

View file

@ -0,0 +1,12 @@
declare
fun {FizzBuzz X}
if X mod 15 == 0 then 'FizzBuzz'
elseif X mod 3 == 0 then 'Fizz'
elseif X mod 5 == 0 then 'Buzz'
else X
end
end
in
for I in 1..100 do
{Show {FizzBuzz I}}
end

View file

@ -0,0 +1,15 @@
{for(n=1,100,
print(if(n%3,
if(n%5,
n
,
"Buzz"
)
,
if(n%5,
"Fizz"
,
"FizzBuzz"
)
))
)}

View file

@ -0,0 +1,8 @@
do i = 1 to 100;
select;
when (mod(i,15) = 0) put skip list ('FizzBuzz');
when (mod(i,3) = 0) put skip list ('Fizz');
when (mod(i,5) = 0) put skip list ('Buzz');
otherwise put skip list (i);
end;
end;

View file

@ -0,0 +1,17 @@
CREATE OR REPLACE PROCEDURE FIZZBUZZ AS
i NUMBER;
BEGIN
FOR i in 1 .. 100 LOOP
IF MOD(i, 15) = 0 THEN
DBMS_OUTPUT.PUT_LINE('FizzBuzz');
ELSIF MOD(i, 5) = 0 THEN
DBMS_OUTPUT.PUT_LINE('Buzz');
ELSIF MOD(i, 3) = 0 THEN
DBMS_OUTPUT.PUT_LINE('Fizz');
ELSE
DBMS_OUTPUT.PUT_LINE(i);
END IF;
END LOOP;
END FIZZBUZZ;

View file

@ -0,0 +1,14 @@
program fizzbuzz(output);
var
i: integer;
begin
for i := 1 to 100 do
if i mod 15 = 0 then
writeln('FizzBuzz')
else if i mod 3 = 0 then
writeln('Fizz')
else if i mod 5 = 0 then
writeln('Buzz')
else
writeln(i)
end.

View file

@ -0,0 +1,6 @@
for 1 .. 100 {
when $_ %% (3 & 5) { say 'FizzBuzz'; }
when $_ %% 3 { say 'Fizz'; }
when $_ %% 5 { say 'Buzz'; }
default { .say; }
}

View file

@ -0,0 +1,5 @@
multi sub fizzbuzz(Int $ where * %% 15) { 'FizzBuzz' }
multi sub fizzbuzz(Int $ where * %% 5) { 'Buzz' }
multi sub fizzbuzz(Int $ where * %% 3) { 'Fizz' }
multi sub fizzbuzz(Int $number ) { $number }
(1 .. 100)».&fizzbuzz.join("\n").say;

View file

@ -0,0 +1 @@
say 'Fizz' x $_ %% 3 ~ 'Buzz' x $_ %% 5 || $_ for 1 .. 100;

View file

@ -0,0 +1,4 @@
.say for
(('' xx 2, 'Fizz') xx * Z~
('' xx 4, 'Buzz') xx *) Z||
1 .. 100;

View file

@ -0,0 +1,13 @@
int main(){
for(int i = 1; i <= 100; i++) {
if(i % 15 == 0) {
write("FizzBuzz\n");
} else if(i % 3 == 0) {
write("Fizz\n");
} else if(i % 5 == 0) {
write("Buzz\n");
} else {
write(i + "\n");
}
}
}

View file

@ -0,0 +1,13 @@
lvars str;
for i from 1 to 100 do
if i rem 15 = 0 then
'FizzBuzz' -> str;
elseif i rem 3 = 0 then
'Fizz' -> str;
elseif i rem 5 = 0 then
'Buzz' -> str;
else
'' >< i -> str;
endif;
printf(str, '%s\n');
endfor;

View file

@ -0,0 +1,7 @@
1 1 100 {
/c false def
dup 3 mod 0 eq { (Fizz) print /c true def } if
dup 5 mod 0 eq { (Buzz) print /c true def } if
c {pop}{( ) cvs print} ifelse
(\n) print
} for

View file

@ -0,0 +1,11 @@
/fizzdict 100 dict def
fizzdict begin
/notmod{ ( ) cvs } def
/mod15 { dup 15 mod 0 eq { (FizzBuzz)def }{pop}ifelse} def
/mod3 { dup 3 mod 0 eq {(Fizz)def}{pop}ifelse} def
/mod5 { dup 5 mod 0 eq {(Buzz)def}{pop}ifelse} def
1 1 100 { mod3 } for
1 1 100 { mod5 } for
1 1 100 { mod15} for
1 1 100 { dup currentdict exch known { currentdict exch get}{notmod} ifelse print (\n) print} for
end

View file

@ -0,0 +1,11 @@
for ($i = 1; $i -le 100; $i++) {
if ($i % 15 -eq 0) {
"FizzBuzz"
} elseif ($i % 5 -eq 0) {
"Buzz"
} elseif ($i % 3 -eq 0) {
"Fizz"
} else {
$i
}
}

View file

@ -0,0 +1,8 @@
$txt=$null
1..100 | ForEach-Object {
switch ($_) {
{ $_ % 3 -eq 0 } { $txt+="Fizz" }
{ $_ % 5 -eq 0 } { $txt+="Buzz" }
$_ { if($txt) { $txt } else { $_ }; $txt=$null }
}
}

View file

@ -0,0 +1,7 @@
1..100 | ForEach-Object {
$s = ''
if ($_ % 3 -eq 0) { $s += "Fizz" }
if ($_ % 5 -eq 0) { $s += "Buzz" }
if (-not $s) { $s = $_ }
$s
}

View file

@ -0,0 +1,9 @@
<# DEFINE USERDEFINEDROUTINE LITERAL>__FizzBuzz|<# SUPPRESSAUTOMATICWHITESPACE>
<# TEST ISITMODULUSZERO PARAMETER LITERAL>1|3</#>
<# TEST ISITMODULUSZERO PARAMETER LITERAL>1|5</#>
<# ONLYFIRSTOFLASTTWO><# SAY LITERAL>Fizz</#></#>
<# ONLYSECONDOFLASTTWO><# SAY LITERAL>Buzz</#></#>
<# BOTH><# SAY LITERAL>FizzBuzz</#></#>
<# NEITHER><# SAY PARAMETER>1</#></#>
</#></#>
<# ITERATE FORITERATION LITERAL LITERAL>100|<# ACT USERDEFINEDROUTINE POSITION FORITERATION>__FizzBuzz|...</#> </#>

View file

@ -0,0 +1,9 @@
<@ DEFUDRLIT>__FizzBuzz|<@ SAW>
<@ TSTMD0PARLIT>1|3</@>
<@ TSTMD0PARLIT>1|5</@>
<@ O12><@ SAYLIT>Fizz</@></@>
<@ O22><@ SAYLIT>Buzz</@></@>
<@ BTH><@ SAYLIT>FizzBuzz</@></@>
<@ NTH><@ SAYPAR>1</@></@>
</@></@>
<@ ITEFORLITLIT>100|<@ ACTUDRPOSFOR>__FizzBuzz|...</@> </@>

View file

@ -0,0 +1,13 @@
OpenConsole()
For x = 1 To 100
If x%15 = 0
PrintN("FizzBuzz")
ElseIf x%3 = 0
PrintN("Fizz")
ElseIf x%5 = 0
PrintN("Buzz")
Else
PrintN(Str(x))
EndIf
Next
Input()

View file

@ -0,0 +1 @@
repeat i 100 [case/all [i // 3 = 0 [print"fizz"] i // 5 = 0 [print "buzz"] 1 [print i]]]

View file

@ -0,0 +1,20 @@
REBOL [
Title: "FizzBuzz"
Author: oofoe
Date: 2009-12-10
URL: http://rosettacode.org/wiki/FizzBuzz
]
; Concatenative. Note use of 'case/all' construct to evaluate all
; conditions. I use 'copy' to allocate a new string each time through
; the loop -- otherwise 'x' would get very long...
repeat i 100 [
x: copy ""
case/all [
0 = mod i 3 [append x "Fizz"]
0 = mod i 5 [append x "Buzz"]
"" = x [x: mold i]
]
print x
]

View file

@ -0,0 +1,11 @@
repeat i 100 [
print switch/default 0 compose [
(mod i 15) ["fizzbuzz"]
(mod i 3) ["fizz"]
(mod i 5) ["buzz"]
][i]
]
; And minimized version:
repeat i 100[j:""if 0 = mod i 3[j:"fizz"]if 0 = mod i 5[j: join j"buzz"]if j =""[j: i]print j]

View file

@ -0,0 +1,4 @@
m: func [i d] [0 = mod i d]
spick: func [t x y][either any [not t "" = t][y][x]]
zz: func [i] [rejoin [spick m i 3 "Fizz" "" spick m i 5 "Buzz" ""]]
repeat i 100 [print spick z: zz i z i]

View file

@ -0,0 +1,4 @@
FOR i=1 TO 100
t$ = IIF(i MOD 3 = 0, "Fizz", "") + IIF(i MOD 5 = 0, "Buzz", "")
PRINT IIF(LEN(t$), t$, i)
NEXT i

View file

@ -0,0 +1,8 @@
import IO;
public void fizzbuzz() {
for(int n <- [1 .. 100]){
fb = ((n % 3 == 0) ? "Fizz" : "") + ((n % 5 == 0) ? "Buzz" : "");
println((fb == "") ?"<n>" : fb);
}
}

View file

@ -0,0 +1,6 @@
100 each 1 + as n
''
n 3 mod 0 = if 'Fizz' cat
n 5 mod 0 = if 'Buzz' cat
dup empty if drop n
say

View file

@ -0,0 +1,8 @@
: fizz? ( s-f ) 3 mod 0 = ;
: buzz? ( s-f ) 5 mod 0 = ;
: num? ( s-f ) dup fizz? swap buzz? or 0 = ;
: ?fizz ( s- ) fizz? [ "Fizz" puts ] ifTrue ;
: ?buzz ( s- ) buzz? [ "Buzz" puts ] ifTrue ;
: ?num ( s- ) num? &putn &drop if ;
: fizzbuzz ( s- ) dup ?fizz dup ?buzz dup ?num space ;
: all ( - ) 100 [ 1+ fizzbuzz ] iter ;

View file

@ -0,0 +1,6 @@
needs math'
: <fizzbuzz>
[ 15 ^math'divisor? ] [ drop "FizzBuzz" puts ] when
[ 3 ^math'divisor? ] [ drop "Fizz" puts ] when
[ 5 ^math'divisor? ] [ drop "Buzz" puts ] when putn ;
: fizzbuzz cr 100 [ 1+ <fizzbuzz> space ] iter ;

View file

@ -0,0 +1,6 @@
for i = 1 to 100
print i;
if (i mod 3) = 0 then print " Fuzz";
if (i mod 5) = 0 then print " Buzz";
print
next i

View file

@ -0,0 +1,18 @@
fn main() {
let mut n = 1;
while n <= 100 {
if n % 15 == 0 {
io::println("FizzBuzz");
}
else if n % 3 == 0 {
println("Fizz");
}
else if n % 5 == 0 {
io::println("Buzz");
}
else {
io::println(int::to_str(n));
}
n += 1;
}
}

View file

@ -0,0 +1,8 @@
fn main() {
for int::range(1, 101) |i| {
if i % 15 == 0 { io::println("FizzBuzz") }
else if i % 3 == 0 { io::println("Fizz") }
else if i % 5 == 0 { io::println("Buzz") }
else { io::println(int::str(i)) }
}
}

View file

@ -0,0 +1,12 @@
fn main() {
for int::range(1, 101) |num| {
io::println(
match (num % 3, num % 5) {
(0, 0) => ~"FizzBuzz",
(0, _) => ~"Fizz",
(_, 0) => ~"Buzz",
(_, _) => int::str(num)
}
);
}
}

View file

@ -0,0 +1,12 @@
fn main() {
for int::range(1, 101) |num| {
io::println(
match (num % 3 == 0, num % 5 == 0) {
(false, false) => int::str(num),
(true, false) => ~"Fizz",
(false, true) => ~"Buzz",
(true, true) => ~"FizzBuzz"
}
);
}
}

View file

@ -0,0 +1,12 @@
I = 1
LOOP FIZZBUZZ = ""
EQ(REMDR(I, 3), 0) :F(TRY_5)
FIZZBUZZ = FIZZBUZZ "FIZZ"
TRY_5 EQ(REMDR(I, 5), 0) :F(DO_NUM)
FIZZBUZZ = FIZZBUZZ "BUZZ"
DO_NUM IDENT(FIZZBUZZ, "") :F(SHOW)
FIZZBUZZ = I
SHOW OUTPUT = FIZZBUZZ
I = I + 1
LE(I, 100) :S(LOOP)
END

View file

@ -0,0 +1,18 @@
DROP TABLE fizzbuzz;
CREATE TABLE fizzbuzz(i int, fizz string, buzz string);
INSERT INTO fizzbuzz VALUES(1,"","");
INSERT INTO fizzbuzz SELECT i + (SELECT max(i) FROM fizzbuzz), fizz, buzz FROM fizzbuzz;
INSERT INTO fizzbuzz SELECT i + (SELECT max(i) FROM fizzbuzz), fizz, buzz FROM fizzbuzz;
INSERT INTO fizzbuzz SELECT i + (SELECT max(i) FROM fizzbuzz), fizz, buzz FROM fizzbuzz;
INSERT INTO fizzbuzz SELECT i + (SELECT max(i) FROM fizzbuzz), fizz, buzz FROM fizzbuzz;
INSERT INTO fizzbuzz SELECT i + (SELECT max(i) FROM fizzbuzz), fizz, buzz FROM fizzbuzz;
INSERT INTO fizzbuzz SELECT i + (SELECT max(i) FROM fizzbuzz), fizz, buzz FROM fizzbuzz;
INSERT INTO fizzbuzz SELECT i + (SELECT max(i) FROM fizzbuzz), fizz, buzz FROM fizzbuzz;
DROP TABLE lookup;
CREATE TABLE lookup (fizzy, buzzy, rem);
INSERT INTO lookup VALUES("fizz", "buzz", 1);
SELECT
(SELECT i FROM lookup WHERE rem = (i%3<>0)&(i%5<>0)),
(SELECT fizzy FROM lookup WHERE rem = (i%3=0)),
(SELECT buzzy FROM lookup WHERE rem = (i%5=0))
FROM fizzbuzz WHERE i <= 100;

View file

@ -0,0 +1,11 @@
SELECT i, fizzbuzz
FROM
(SELECT i,
CASE
WHEN i % 15 = 0 THEN 'FizzBuzz'
WHEN i % 5 = 0 THEN 'Buzz'
WHEN i % 3 = 0 THEN 'Fizz'
ELSE NULL
END AS fizzbuzz
FROM generate_series(1,100) AS i) AS fb
WHERE fizzbuzz IS NOT NULL;

View file

@ -0,0 +1,10 @@
select (CASE
WHEN MOD(lvl,15)=0 THEN 'FizzBuzz'
WHEN MOD(lvl,3)=0 THEN 'Fizz'
WHEN MOD(lvl,5)=0 THEN 'Buzz'
ELSE TO_CHAR(lvl)
END) FizzBuzz
from (
select LEVEL lvl
from dual
connect by LEVEL <= 100)

View file

@ -0,0 +1,15 @@
WITH nums (n, fizzbuzz ) AS (
SELECT 1, CONVERT(nvarchar, 1) UNION ALL
SELECT
(n + 1) as n1,
CASE
WHEN (n + 1) % 15 = 0 THEN 'FizzBuzz'
WHEN (n + 1) % 3 = 0 THEN 'Fizz'
WHEN (n + 1) % 5 = 0 THEN 'Buzz'
ELSE CONVERT(nvarchar, (n + 1))
END
FROM nums WHERE n < 100
)
SELECT n, fizzbuzz FROM nums
ORDER BY n ASC
OPTION ( MAXRECURSION 100 )

View file

@ -0,0 +1,16 @@
declare
v_count integer;
begin
for v_count in 1..100 loop
if(mod(v_count, 15) = 0) then
dbms_output.put_line('Fizz Buzz');
elsif(mod(v_count, 3) = 0) then
dbms_output.put_line('Fizz');
elsif(mod(v_count, 5) = 0) then
dbms_output.put_line('Buzz');
else
dbms_output.put_line(v_count);
end if;
end loop;
end;

View file

@ -0,0 +1,4 @@
iterate (x; [1...100])
((x % 15 == 0) ? "FizzBuzz" :
((x % 3 == 0) ? "Fizz" :
((x % 5 == 0) ? "Buzz" : x)))!;

View file

@ -0,0 +1,11 @@
iterate (x; [1...100])
{
if (x % 15 == 0)
"FizzBuzz"!
else if (x % 3 == 0)
"Fizz"!
else if (x % 5 == 0)
"Buzz"!
else
x!;
};

View file

@ -0,0 +1,18 @@
$ include "seed7_05.s7i";
const proc: main is func
local
var integer: number is 0;
begin
for number range 1 to 100 do
if number rem 15 = 0 then
writeln("FizzBuzz");
elsif number rem 5 = 0 then
writeln("Buzz");
elsif number rem 3 = 0 then
writeln("Fizz");
else
writeln(number);
end if;
end for;
end func;

View file

@ -0,0 +1,6 @@
n@(Integer traits) fizzbuzz
[
output ::= ((n \\ 3) isZero ifTrue: ['Fizz'] ifFalse: ['']) ; ((n \\ 5) isZero ifTrue: ['Buzz'] ifFalse: ['']).
output isEmpty ifTrue: [n printString] ifFalse: [output]
].
1 to: 100 do: [| :i | inform: i fizzbuzz]

View file

@ -0,0 +1,14 @@
function Fizzbuzz(n) {
for (local i = 1; i <= n; i += 1) {
if (i % 15 == 0)
print ("FizzBuzz\n")
else if (i % 5 == 0)
print ("Buzz\n")
else if (i % 3 == 0)
print ("Fizz\n")
else {
print (i + "\n")
}
}
}
Fizzbuzz(100);

View file

@ -0,0 +1,14 @@
fun output x =
case (x mod 3 = 0, x mod 5 = 0) of
(true , true ) => "FizzBuzz"
| (true , false) => "Fizz"
| (false, true ) => "Buzz"
| (false, false) => Int.toString x
val () = let
fun aux i = if i <= 100 then (print (output i ^ "\n");
aux (i+1))
else ()
in
aux 1
end

View file

@ -0,0 +1,16 @@
PROGRAM:FIZZBUZZ
:For(I,1,100)
:0→N
:If fPart(I/5)=0
:2→N
:If fPart(I/3)=0
:1+N→N
:If N=0
:Disp I
:If N=1
:Disp "FIZZ"
:If N=2
:Disp "BUZZ"
:If N=3
:Disp "FIZZBUZZ"
:End

View file

@ -0,0 +1,14 @@
$$ MODE TUSCRIPT
LOOP n=1,100
mod=MOD (n,15)
SELECT mod
CASE 0
PRINT n," FizzBuzz"
CASE 3,6,9,12
PRINT n," Fizz"
CASE 5,10
PRINT n," Buzz"
DEFAULT
PRINT n
ENDSELECT
ENDLOOP

View file

@ -0,0 +1,8 @@
i=1
while expr $i '<=' 100 >/dev/null; do
w=false
expr $i % 3 = 0 >/dev/null && { printf Fizz; w=true; }
expr $i % 5 = 0 >/dev/null && { printf Buzz; w=true; }
if $w; then echo; else echo $i; fi
i=`expr $i + 1`
done

View file

@ -0,0 +1,11 @@
for n in `seq 1 100`; do
if [ $((n % 15)) = 0 ]; then
echo FizzBuzz
elif [ $((n % 3)) = 0 ]; then
echo Fizz
elif [ $((n % 5)) = 0 ]; then
echo Buzz
else
echo $n
fi
done

View file

@ -0,0 +1,13 @@
NUM=1
until ((NUM == 101)) ; do
if ((NUM % 15 == 0)) ; then
echo FizzBuzz
elif ((NUM % 3 == 0)) ; then
echo Fizz
elif ((NUM % 5 == 0)) ; then
echo Buzz
else
echo "$NUM"
fi
((NUM = NUM + 1))
done

View file

@ -0,0 +1,7 @@
for ((n=1; n<=100; n++))
do
fb=''
[ $(( n % 3 )) -eq 0 ] && fb="${fb}Fizz"
[ $(( n % 5 )) -eq 0 ] && fb="${fb}Buzz"
[ -n "${fb}" ] && echo "${fb}" || echo "$n"
done

View file

@ -0,0 +1,10 @@
command_not_found_handle () {
local Fizz=3 Buzz=5
[ $(( $2 % $1 )) -eq 0 ] && echo -n $1 && [ ${!1} -eq 3 ]
}
for i in {1..100}
do
Fizz $i && ! Buzz $i || echo -n $i
echo
done

View file

@ -0,0 +1 @@
for i in {1..100};do ((($i%15==0))&& echo FizzBuzz)||((($i%5==0))&& echo Buzz;)||((($i%3==0))&& echo Fizz;)||echo $i;done

View file

@ -0,0 +1,8 @@
#import std
#import nat
fizzbuzz = ^T(&&'Fizz'! not remainder\3,&&'Buzz'! not remainder\5)|| ~&h+ %nP
#show+
main = fizzbuzz*t iota 101

View file

@ -0,0 +1,9 @@
[fizzbuzz
1 [>=] [
[[15 % zero?] ['fizzbuzz' puts]
[5 % zero?] ['buzz' puts]
[3 % zero?] ['fizz' puts]
[true] [dup puts]
] when succ
] while].
|100 fizzbuzz

View file

@ -0,0 +1 @@
[seq [] swap dup [zero? not] [rolldown [dup] dip cons rollup pred] while pop pop].

View file

@ -0,0 +1 @@
[check [N X F : [[integer?] [[X % zero?] [N F cons] if] if]] view].

View file

@ -0,0 +1 @@
[func [[N F] : [dup N F check i] ] view map].

View file

@ -0,0 +1,6 @@
100 seq [
[15 [pop 'fizzbuzz' puts]]
[5 [pop 'buzz' puts]]
[3 [pop 'fizz' puts]]
[1 [puts]]] [func dup] step
[i true] map pop

View file

@ -0,0 +1,26 @@
'using the IF/ELSEIF ladder
function fb( n )
if n mod 15 = 0 then
fb = "FizzBuzz"
elseif n mod 5 = 0 then
fb = "Fizz"
elseif n mod 3 = 0 then
fb = "Buzz"
else
fb = n
end if
end function
'the Mexican IF
function eef( b, p1, p2 )
if b then
eef = p1
else
eef = p2
end if
end function
'using the Mexican IF
function fb2( n )
fb2 = eef( n mod 15 = 0, "FizzBuzz", eef( n mod 5 = 0, "Fizz", eef( n mod 3 = 0, "Buzz", n ) ) )
end function

View file

@ -0,0 +1,9 @@
for i = 1 to 16
wscript.stdout.write fb(i) & " "
next
wscript.echo
for i = 1 to 16
wscript.stdout.write fb2(i) & " "
next
wscript.echo

View file

@ -0,0 +1,9 @@
int main() {
for(int i = 1; i < 100; i++) {
if(i % 3 == 0) stdout.printf("Fizz");
if(i % 5 == 0) stdout.printf("Buzz");
if(i % 3 != 0 && i % 5 != 0) stdout.printf("%d", i);
stdout.printf("\n");
}
return 0;
}

View file

@ -0,0 +1,15 @@
Sub Main()
For i = 1 To 100
If i Mod 15 = 0 Then
Console.WriteLine("FizzBuzz")
ElseIf i Mod 5 = 0 Then
Console.WriteLine("Buzz")
ElseIf i Mod 3 = 0 Then
Console.WriteLine("Fizz")
Else
Console.WriteLine(i)
End If
Next
End Sub

View file

View file

@ -0,0 +1,29 @@
push 1 ; Initialize a counter.
0:
dup dup ; Get two copies for the mod checks.
push 3 mod jz 1
push 5 mod jz 2
dup onum jump 4 ; If we're still here, just print the number.
1: ; Print "Fizz", then maybe "Buzz".
push F ochr
push i ochr
call 3 push 5 mod
jz 2
jump 4
2: ; Print "Buzz".
push B ochr
push u ochr
call 3 jump 4
3: ; Print "zz"; called as a function for convenient return.
push z dup ochr ochr ret
4:
push 10 ochr ; Print a newline.
push 1 add dup ; Increment the counter.
push 101 sub
jn 0 ; Go again unless we're at 100.
pop exit ; Exit clean.

View file

@ -0,0 +1,9 @@
code CrLf=9, IntOut=11, Text=12;
int N;
[for N:= 1 to 100 do
[if rem(N/3)=0 then Text(0,"Fizz");
if rem(N/5)=0 then Text(0,"Buzz")
else if rem(N/3)#0 then IntOut(0,N);
CrLf(0);
];
]

View file

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" encoding="utf-8"/>
<!-- Outputs a line for a single FizzBuzz iteration. -->
<xsl:template name="fizzbuzz-single">
<xsl:param name="n"/>
<!-- $s will be "", "Fizz", "Buzz", or "FizzBuzz". -->
<xsl:variable name="s">
<xsl:if test="$n mod 3 = 0">Fizz</xsl:if>
<xsl:if test="$n mod 5 = 0">Buzz</xsl:if>
</xsl:variable>
<!-- Output $s. If $s is blank, also output $n. -->
<xsl:value-of select="$s"/>
<xsl:if test="$s = ''">
<xsl:value-of select="$n"/>
</xsl:if>
<!-- End line. -->
<xsl:value-of select="'&#10;'"/>
</xsl:template>
<!-- Calls fizzbuzz-single over each value in a range. -->
<xsl:template name="fizzbuzz-range">
<!-- Default parameters: From 1 through 100 -->
<xsl:param name="startAt" select="1"/>
<xsl:param name="endAt" select="$startAt + 99"/>
<!-- Simulate a loop with tail recursion. -->
<!-- Loop condition -->
<xsl:if test="$startAt &lt;= $endAt">
<!-- Loop body -->
<xsl:call-template name="fizzbuzz-single">
<xsl:with-param name="n" select="$startAt"/>
</xsl:call-template>
<!-- Increment counter, repeat -->
<xsl:call-template name="fizzbuzz-range">
<xsl:with-param name="startAt" select="$startAt + 1"/>
<xsl:with-param name="endAt" select="$endAt"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<!-- Main procedure -->
<xsl:template match="/">
<!-- Default parameters are used -->
<xsl:call-template name="fizzbuzz-range"/>
</xsl:template>
</xsl:stylesheet>

View file

@ -0,0 +1,33 @@
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
exclude-result-prefixes="xsl exsl">
<xsl:output method="text"/>
<xsl:template name="FizzBuzz" match="/">
<xsl:param name="n" select="1" />
<xsl:variable name="_">
<_><xsl:value-of select="$n" /></_>
</xsl:variable>
<xsl:apply-templates select="exsl:node-set($_)/_" />
<xsl:if test="$n < 100">
<xsl:call-template name="FizzBuzz">
<xsl:with-param name="n" select="$n + 1" />
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template match="_[. mod 3 = 0]">Fizz
</xsl:template>
<xsl:template match="_[. mod 5 = 0]">Buzz
</xsl:template>
<xsl:template match="_[. mod 15 = 0]" priority="1">FizzBuzz
</xsl:template>
<xsl:template match="_">
<xsl:value-of select="concat(.,'&#x0A;')" />
</xsl:template>
</xsl:stylesheet>

View file

@ -0,0 +1,10 @@
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:value-of separator="&#x0A;" select="
for $n in 1 to 100 return
concat('fizz'[not($n mod 3)], 'buzz'[not($n mod 5)], $n[$n mod 15 = (1,2,4,7,8,11,13,14)])"/>
</xsl:template>
</xsl:stylesheet>

View file

@ -0,0 +1,9 @@
for(i = 1; i <= 100; i++) {
if(i % 3 == 0)
write, format="%s", "Fizz";
if(i % 5 == 0)
write, format="%s", "Buzz";
if(i % 3 && i % 5)
write, format="%d", i;
write, "";
}

View file

@ -0,0 +1,5 @@
output = swrite(format="%d", indgen(100));
output(3::3) = "Fizz";
output(5::5) = "Buzz";
output(15::15) = "FizzBuzz";
write, format="%s\n", output;