We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.
Project Euler/1
The first problem from Project Euler requires a program to return the sum of all the multiples of 3 and 5 which are less than 1,000.
As an example, summing all multiples of 3 and 5 less than 10 yields:
3 + 5 + 6 + 9 = 23
Implementations
Aheui
This program needs reduction due to no-op chains.
바싹밣발발발따따뚜 루벌루벋뻐터너벌벌 우뽀처빠쑥사빠아초희멍 처아아오삭도오어샥여오여
AsciiDots
This program unfortunately fails on Try It Online, probably because Try It Online does not allow setting the value to 0.
`,` /-------\
`,` .->---{+}-~-$#&
`,` /------->-----^ |
`,` /*\ /*\ | |
`,` /---~-+\/---~-+\ | |
`,` | ! ||| ! || | |
`,` .-#1000->*-{-}-*#3[%]|\*#5[%]|\*#0/ |
`,` |\#1/ \---/ | \---/ | | |
`,` | \------->->-----*
`,` \----------------------------/
C
#include <stdio.h>
i=0,r=0;main(){while(i++<999)if(i%3==0||i%5==0)r+=i;printf("%d",r);}
C♯
using System;
class Program {
static void Main() {
int total = 0;
for (int num = 1; num <= 999; num++) {
if (num % 15 == 0) {
Console.WriteLine("FizzBuzz");
total += num;
} else if (num % 3 == 0) {
Console.WriteLine("Fizz");
total += num;
} else if (num % 5 == 0) {
Console.WriteLine("Buzz");
total += num;
}
}
Console.WriteLine(total);
}
}
Don Giovanni
let FLAG_FIZZ = 1;
let FLAG_BUZZ = 2;
let accumulator = 0;
fn check(n) {
let flags = 0;
if n % 3 == 0 { flags = flags | FLAG_FIZZ; }
if n % 5 == 0 { flags = flags | FLAG_BUZZ; }
return flags;
}
let i = 1;
while i <= 999 {
let f = check(i);
if f == 0 {
print(i);
} else {
if f == 1 { print("Fizz"); accumulator = accumulator + f; }
if f == 2 { print("Buzz"); accumulator = accumulator + f; }
if f == 3 { print("FizzBuzz"); accumulator = accumulator + f; }
}
i = i + 1;
}
print(f);
I fuck, you fuck
There's a fucker named a Fuck a 999 times There's a fucker named b Fuck b 3 times There's a fucker named c Fuck c 5 times There's a fucker named d There's a fucker named e I fuck e while a is fucked a unfucks b over and over a unfucks c over and over b fucks e again c fucks e again b unfucks b c unfucks c Fuck b 3 times Fuck c 5 times if e is unfucked a fucks d end fuck e unfucks e I fuck e I unfuck a end fuck d fucks you
Lua
t=0 for i=1,999 do t=i%3*i%5==0 and t+i or t end print(t)
MoreMathRPN
0 repeat 999 >>> 0 3 % step 5 * jmp ]0 del 0 >>> 0 + jmp 14 del 0 >>> 0 5 % step 5 * jmp ]0 del 0 >>> 0 + jmp 2 del 0 next outputV
Polynomix
1#\x 0#\acc x<1000 @ {acc#+((((x%3)=0)|((x%5)=0))?(x 0)) x#+1} acc>.
Python
By User:None1:
print(sum(filter(lambda x:x%3==0 or x%5==0,range(1,1000))))
By User:GUAqwq:
A shortened version is provided.
print(sum([x*(x%3*x%5==0)for x in range(1000)]))
By User:PrySigneToFry:
Note that I've intergrated two programs.
i = 999
j = 0
for k in range(1, i + 1, 1):
if k % 15 == 0:
print("FizzBuzz")
j += k
elif k % 5 == 0:
print("Buzz")
j += k
elif k % 3 == 0:
print("Fizz")
j += k
else:
print(k)
j += 0
print(f"The sum of all multiples of 3, 5, and 15 within a thousand is {j}.")
Rust
fn main() {
let mut total = 0;
for num in 1..=999 {
if num % 15 == 0 {
println!("FizzBuzz");
total += num;
} else if num % 3 == 0 {
println!("Fizz");
total += num;
} else if num % 5 == 0 {
println!("Buzz");
total += num;
}
}
println!("{}", total);
}
Shakespeare
This code may be shortened using the operators "cube" and "remainder".
The Euler Plan. Hamlet, who adds everything up. Juliet, who always counts down. Act I:a. Scene I: define constant. [ enter Hamlet and Juliet ] Hamlet: You are twice twice twice the sum of the sum of a big big big big big big big cat and a big pig and a pig. Scene II: start loop. Hamlet: you are the sum of you and a pig. Hamlet: Are you as good as the product of the quotient between you and the sum of a big cat and a cat and the sum of a big cat and a cat? If so, let us proceed to Scene III. Hamlet: Are you as good as the product of the quotient between you and the sum of a big big cat and a cat and the sum of a big big cat and a cat? If so, let us proceed to Scene III. If not, let us proceed to Scene II. Scene III: Add numbers. Juliet: You are the sum of you and me. Hamlet: Are you as good as nothing? If not, let us proceed to Scene II. Juliet: Open your heart. [ exeunt ]
SLet
Version 3:
let fizz range 3 1000 3 let buzz range 5 1000 5 let fizzbuzz combine fizz buzz all let sum 0 for fizzbuzz i do let sum add sum i all print sum
Version 4:
#s 0~|]3 1000 3]5 1000 5!i\#s+s i!.s
Uiua
It is important to note that "ran1000" in Uiua does not include 1000 as an element.
red add kee off(not min for (mod3)(mod5)) ran1000
Wenyan
有數零。名之曰「饢」。 有數千。名之曰「駿」。 恆為是。若「駿」等於零者乃止也。 減「駿」以一。昔之「駿」者。今其是矣。 除「駿」以三。所餘幾何。 若其等於零者。 加「饢」以「駿」。昔之「饢」者。今其是矣。 若非。 除「駿」以五。所餘幾何。 若其等於零者。 加「饢」以「駿」。昔之「饢」者。今其是矣。 云云。 云云。 云云。 吾有一數。曰「饢」。書之。
XYScript
令 数字 为 1 令 累加器 为 0 当 阳 循环 若 数字 等于 1000 则 跳出 结束 令 三倍@爻 为 数字 取模 3 等于 0 令 五倍@爻 为 数字 取模 5 等于 0 若 三倍 或 五倍 则 令 累加器 为 累加器 加 数字 结束 结束循环 输出 累加器
喵谕 Meaoiu
Modeled after islptng's FizzBuzz program since PSTF didn't got response from TNPC.
蹭 数字 就是 1~ 蹭 累加器 就是 0~ 玩耍 [# [# 累了~ #] 好不好? 数字 == 1000~ 蹭 三倍 就是 扒 [= 数字, 3 =] 摸余 == 0~ 蹭 五倍 就是 扒 [= 数字, 5 =] 摸余 == 0~ [# 累加器 就是 累加器 + 数字~ #] 好不好? 三倍 和 五倍 都好 不然 [# [# 累加器 就是 累加器 + 数字~ #] 好不好? 三倍 不然 [# [# 累加器 就是 累加器 + 数字~ #] 好不好? 五倍 不然 [# 扒 [= 数字 =] 喵~ #]~ #]~ #]~ 数字 就是 数字 + 1~ #]~ 扒 [= 累加器 =] 喵~
See also
| << | < | 1 | ... | 2 | 3 | 4 | 5 | 6 | ... | 28 | > | >> |
|---|