Finished PE 097, easy introduction to mod
This commit is contained in:
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