rustleaf 0.1.0

A simple programming language interpreter written in Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// <p>If we list all the natural numbers below $10$ that are multiples of $3$ or $5$, we get $3, 5, 6$ and $9$. The sum of these multiples is $23$.</p>
// <p>Find the sum of all the multiples of $3$ or $5$ below $1000$.</p>

fn solve_euler_001(x) {
    range(1, x)
        | filter(|i| i % 3 == 0 or i % 5 == 0)
        | sum()
}

// Test the example first
var example_result = solve_euler_001(10);
assert(example_result == 23);

// Solve the actual problem
var result = solve_euler_001(1000);
print("The sum of all multiples of 3 or 5 below 1000 is: ${result}");
assert(result == 233168);