Finished PE 097, easy introduction to mod
This commit is contained in:
8
projecteuler/097/Cargo.toml
Normal file
8
projecteuler/097/Cargo.toml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
[package]
|
||||||
|
name = "main"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
22
projecteuler/097/src/main.rs
Normal file
22
projecteuler/097/src/main.rs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
use std::time::Instant;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
println!("Hello, this is Patrick!");
|
||||||
|
let now = Instant::now();
|
||||||
|
|
||||||
|
const POWER: u64 = 7830457;
|
||||||
|
const PRODUCT: u64 = 28433;
|
||||||
|
const MOD: u64 = 10000000000;
|
||||||
|
|
||||||
|
let mut n = 1;
|
||||||
|
|
||||||
|
for _ in 0..POWER {
|
||||||
|
n = (2 * n) % MOD;
|
||||||
|
}
|
||||||
|
|
||||||
|
n = (PRODUCT * n + 1) % MOD;
|
||||||
|
|
||||||
|
println!("{}", n);
|
||||||
|
|
||||||
|
println!("Time passed: {:?}", Instant::now() - now);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user