Skip to content

Commit 88b245a

Browse files
replace .pow with mod_exp
1 parent 0fef996 commit 88b245a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ pub fn primitive_root(p: i64, e: u32) -> i64 {
161161
let mut g_lifted = g; // Lift it to p^e
162162
for _ in 1..e {
163163
println!("g_lifted: {}", g_lifted);
164-
if g_lifted.pow((p - 1) as u32) % p.pow(e) == 1 {
164+
if mod_exp(g_lifted, p-1, p.pow(e)) == 1 {
165165
g_lifted += p.pow(e - 1);
166166
}
167167
}

0 commit comments

Comments
 (0)