File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,8 @@ pub const fn is_prime(n: u64) -> bool {
45
45
// in order to make the test both fast and deterministic.
46
46
// This list of witnesses was taken from
47
47
// <https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test#Testing_against_small_sets_of_bases>.
48
- const WITNESSES : [ ( u64 , & [ u64 ] ) ; 11 ] = [
48
+ const NUM_BASES : usize = 11 ;
49
+ const WITNESSES : [ ( u64 , & [ u64 ] ) ; NUM_BASES ] = [
49
50
( 2_046 , & [ 2 ] ) ,
50
51
( 1_373_652 , & [ 2 , 3 ] ) ,
51
52
( 9_080_190 , & [ 31 , 73 ] ) ,
@@ -61,7 +62,7 @@ pub const fn is_prime(n: u64) -> bool {
61
62
62
63
// Find the smallest basis that is large enough.
63
64
let mut i = 0 ;
64
- while WITNESSES [ i] . 0 < n {
65
+ while WITNESSES [ i] . 0 < n && i < NUM_BASES {
65
66
i += 1 ;
66
67
}
67
68
let witnesses = WITNESSES [ i] . 1 ;
You can’t perform that action at this time.
0 commit comments