Initial project import

This commit is contained in:
Agila Forge Importer committed 2026-07-13 15:20:32 +00:00
commit 23f2d29e32
11957 files changed
+1754577

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
// This example shows 2 solutions for https://projecteuler.net/problem=1 :
fn gauss_sum(n int) fn (int) int {
return fn [n] (m int) int {
return m * ((n - 1) / m) * ((n - 1) / m + 1) / 2
}
}
gs := gauss_sum(1000)
println('O(1) arithmetic progression sum: ${gs(3) + gs(5) - gs(15)}')
// A brute force solution, by checking every n in the range:
mut sum := 0
for n in 1 .. 1000 {
if n % 3 == 0 || n % 5 == 0 {
sum += n
}
}
println('O(n) brute force calculated sum: ${sum}')