Finished PE 097, easy introduction to mod

This commit is contained in:
2023-06-28 12:58:09 +02:00
parent 3d4e350b89
commit b4f2968846
2 changed files with 30 additions and 0 deletions

View 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);
}