Solution 1

This commit is contained in:
Fabian Schmidt 2024-09-16 12:42:55 +02:00
parent 972edce535
commit 681d9bb96d
2 changed files with 27 additions and 0 deletions

7
Cargo.lock generated Normal file
View File

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "project_euler"
version = "0.1.0"

20
src/bin/problem_1.rs Normal file
View File

@ -0,0 +1,20 @@
fn main() {
let result: i32 = (0..1000)
.into_iter()
.filter(|x| x % 3 == 0 || x % 5 == 0)
.sum();
println!("Result: {}", result);
}
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
let result: i32 = (0..10)
.into_iter()
.filter(|x| x % 3 == 0 || x % 5 == 0)
.sum();
assert_eq!(result, 23);
}
}