i(in [1, 100])行目が
3の倍数なら"Fizz"
5の倍数なら"Buzz"
15の倍数なら"FizzBuzz"
どれでもなければ"i"
https://ja.wikipedia.org/wiki/Fizz_Buzz
https://komari.co.jp/fizzbuzz/ で100/100にする
fish
BEGIN {
for (i=1; i<=100; ++i) {
s = ""
if (i % 15 == 0) s = "FizzBuzz";
else if (i % 3 == 0) s = "Fizz";
else if (i % 5 == 0) s = "Buzz";
else s = i;
print s;
}
}
with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Float_Text_IO;
use Ada.Text_IO;
procedure Program is
I : Integer := 1;
F : String := "FizzBuzz";
begin
for I in 1 .. 100 loop
if I mod 15 = 0 then
Put_Line(F(1..8));
elsif I mod 3 = 0 then
Put_Line(F(1..4));
elsif I mod 5 = 0 then
Put_Line(F(5..8));
else
Put_Line(Integer'Image(I));
end if;
end loop;
end Program;
for ((i=1; i <= 100; i++)); do
if (($i % 15 == 0)); then
echo "FizzBuzz"
elif (($i % 3 == 0)); then
echo "Fizz"
elif (($i % 5 == 0)); then
echo "Buzz"
else
echo $i
fi
done
++++++++++[->>>>++++++++++>+++++++>+++++++>++++++++++>++++++++++++>++++++++++++<
<<<<<<<<]>>>>+>---->>+++++>--->++<<<<<<<<<+++++[->>>>>>>>>>+>+>++>+++<<<<<<<<<<<
<<]>>>>>>>>>>--<<<<<<[-<+>>>>>>>>>>>>>>+<<<<<<<<<<<<<]<[->+<]>>>>>>>>>>[->>+>>>>
>>>>>>+<<<<<<<<<<<<]>>[-<<+>>]<<<<<[->>>>>+>>>>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<<<<
<<<<<]>>>>>[-<<<<<+>>>>>]<<<<[->>>>+>>>>>>>>>>>>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<<<
<<<<<<<<<<<<<]>>>>[-<<<<+>>>>]<<<[->>>+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<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>>>>>>>>>>>>>>>>>>>>>>]>[->[-]>[-]<
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<.>.>>..>>>.>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>]>[->[-]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<.>>>.>..>>>.>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>]>[-<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<[-<+>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
<]<[->+<]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>[->+<<<+>>]<<[->>+<<]>[->>->[
-]>[-]>[-]<<<[->+>+<<]>>[-<<+>>]<[[-]>+<]>>+<[[-]>-<]>[-<<<<[->+>+<<]>>[-<<+>>]>
>>+<]<<<<<]>>>>>>>++++++++++<<<<<[->>>>>-<<<<<]>>>>[->>+>+<<<]>>>[-<<<+>>>]<[[-]
>+<]>>>++++++++[-<++++++>]<[-<<<+<+>>>>]<[-<<<.>>>]<<<[-]>.[-]++++++++++.[-]<<<<
<<<<<<<<]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<+>>>>>>]<<<<<<]
#include <stdio.h>
#include <string.h>
int main() {
for (int i=1; i<=100; ++i) {
if (i % 3 == 0) printf("Fizz");
if (i % 5 == 0) printf("Buzz");
if (i % 3 != 0 && i % 5 != 0) printf("%d", i);
printf("\n");
}
}
using System;
class Program {
static void Main() {
int N, K;
string input = Console.ReadLine();
N = int.Parse(input.Split(' ')[0]);
for (int i = 1; i <= N; i++) {
string output = "";
if (i % 3 == 0) output += "Fizz";
if (i % 5 == 0) output += "Buzz";
if (output == "") output = i.ToString();
Console.WriteLine(output);
}
K = int.Parse(input.Split(' ')[1]);
Console.WriteLine(K);
}
}
#include <iostream>
#include <string>
using namespace std;
int main() {
for (int i=1; i<=100; ++i) {
string s = "";
if (i % 3 == 0) s += "Fizz";
if (i % 5 == 0) s += "Buzz";
if (s == "") s += to_string(i);
cout << s << endl;
}
}
IDENTIFICATION DIVISION.
PROGRAM-ID. MAIN.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WORK-AREA.
03 disp PIC Z(3).
03 I PIC 999.
PROCEDURE DIVISION.
PERFORM VARYING I FROM 1 BY 1 UNTIL I > 100
IF FUNCTION MOD(I, 15) = 0
DISPLAY "FizzBuzz"
ELSE IF FUNCTION MOD(I, 3) = 0
DISPLAY "Fizz"
ELSE IF FUNCTION MOD(I, 5) = 0
DISPLAY "Buzz"
ELSE
COMPUTE disp = I
DISPLAY disp
END-IF
END-PERFORM.
STOP RUN.
END PROGRAM MAIN.
(use IO)
(use String)
(use Int)
(defn fizzbuzz [i n]
(if (< i (+ n 1))
(do
(if (= 0 (mod i 15))
(println* "FizzBuzz")
(do
(if (= 0 (mod i 3))
(println* "Fizz")
(do
(if (= 0 (mod i 5))
(println* "Buzz")
(println &(Int.str i))
)
)
)
)
)
(fizzbuzz (inc i) n)
)
()
)
)
(defn main []
(fizzbuzz 1 100)
)
(loop [i 1]
(cond
(zero? (mod i 15)) (println "FizzBuzz")
(zero? (mod i 3)) (println "Fizz")
(zero? (mod i 5)) (println "Buzz")
:else (println i))
(if (< i 101)
(recur (inc i))
i))
(defun fizzbuzz (n)
(when (< n 101)
(cond
((= 0 (mod n 15))
(write-string "FizzBuzz")
)
((= 0 (mod n 3))
(write-string "Fizz")
)
((= 0 (mod n 5))
(write-string "Buzz")
)
(t
(write-string (write-to-string n))
)
)
(terpri)
(fizzbuzz (+ 1 n))
)
)
(fizzbuzz 1)
n = (1).to_i
while n <= 100
if n % 15 == 0
puts "FizzBuzz"
elsif n % 3 == 0
puts "Fizz"
elsif n % 5 == 0
puts "Buzz"
else
puts n
end
n += 1
end
for 1..101 each 1:
if i % 3 == 0:
prints 'Fizz'
if i % 5 == 0:
prints 'Buzz'
if i % 3 != 0 and i % 5 != 0:
prints '{i}'
print ''
import std.stdio;
void main() {
for (int i=1; i<=100; ++i) {
if (i % 3 == 0) write("Fizz");
if (i % 5 == 0) write("Buzz");
if (i % 3 != 0 && i % 5 != 0) write(i);
writeln("");
}
}
import 'Dart:io';
void main() {
for (int n=1; n<=100; ++n) {
if (n % 3 == 0) stdout.write('Fizz');
if (n % 5 == 0) stdout.write('Buzz');
if (n % 3 != 0 && n % 5 != 0) stdout.write(n);
print('');
}
}
main :-
(
count(N, 1, 100)
do
( N mod 3 =:= 0 ->
write("Fizz")
;
true
),
( N mod 5 =:= 0 ->
write("Buzz")
;
true
),
( N mod 5 =\= 0 , N mod 3 =\= 0 ->
write(N)
;
true
),
nl
).
defmodule Main do
def create_list do
1..100
|> Enum.to_list()
end
def main do
n = Main.create_list()
for x <- n do
if rem(x, 15) == 0 do
IO.puts("FizzBuzz")
else
if rem(x, 3) == 0 do
IO.puts("Fizz")
else
if rem(x, 5) == 0 do
IO.puts("Buzz")
else
IO.puts(x)
end
end
end
end
end
end
(defun solve (n)
(mapcar
(lambda (x)
(cond
((zerop (mod x 15)) "FizzBuzz")
((zerop (mod x 3)) "Fizz")
((zerop (mod x 5)) "Buzz")
(t (number-to-string x))
)
)
n
)
)
(defun main ()
(interactive)
(let
(
(n (number-sequence 1 100))
results
)
(setq results (solve n))
(dolist
(result results)
(princ (format "%s\n" result))
)
)
)
(main)
fun main() {
for (i in 1..100) {
if (i % 3 == 0) print("Fizz")
if (i % 5 == 0) print("Buzz")
if (i % 3 != 0 && i % 5 != 0) print("$i")
println("")
}
}