From f27ed132e9c54f8c3bea4ac606fe1a5e71ca5149 Mon Sep 17 00:00:00 2001 From: Coin de Gamma Date: Sat, 25 Feb 2023 20:56:17 +0000 Subject: [PATCH] 002-ok + readme --- 002/solution.rs | 17 +++++++++++++++++ README.md | 6 ++++++ 2 files changed, 23 insertions(+) create mode 100644 002/solution.rs diff --git a/002/solution.rs b/002/solution.rs new file mode 100644 index 0000000..702b7ca --- /dev/null +++ b/002/solution.rs @@ -0,0 +1,17 @@ +fn main() { + let mut a1 = 1; + let mut a2 = 2; + let mut sum = 0; + + while a2 <= 4_000_000 { + if a2 % 2 == 0 { + sum += a2; + } + let a_new = a1 + a2; + a1 = a2; + a2 = a_new; + // println!("{}", a_new); + } + println!("{}", sum); +} + diff --git a/README.md b/README.md index 50ff993..13e5fdc 100644 --- a/README.md +++ b/README.md @@ -5,3 +5,9 @@ no to actually solve all problems https://projecteuler.net +## run soultion + +```bash +cd 001 +rustc solution.rs && solution +```