@@ -10,15 +10,14 @@ use std::cmp::{max, min};
10
10
11
11
use crate :: numeric:: * ;
12
12
13
- pub ( crate ) fn find_divisor < A : Arithmetic > ( n : A ) -> u64 {
14
- #![ allow( clippy:: many_single_char_names) ]
13
+ pub ( crate ) fn find_divisor < A : Arithmetic > ( input : A ) -> u64 {
15
14
let mut rand = {
16
- let range = Uniform :: new ( 1 , n . modulus ( ) ) ;
15
+ let range = Uniform :: new ( 1 , input . modulus ( ) ) ;
17
16
let mut rng = SmallRng :: from_rng ( & mut thread_rng ( ) ) . unwrap ( ) ;
18
- move || n . to_mod ( range. sample ( & mut rng) )
17
+ move || input . to_mod ( range. sample ( & mut rng) )
19
18
} ;
20
19
21
- let quadratic = |a, b| move |x| n . add ( n . mul ( a, n . mul ( x, x) ) , b) ;
20
+ let quadratic = |a, b| move |x| input . add ( input . mul ( a, input . mul ( x, x) ) , b) ;
22
21
23
22
loop {
24
23
let f = quadratic ( rand ( ) , rand ( ) ) ;
@@ -29,11 +28,11 @@ pub(crate) fn find_divisor<A: Arithmetic>(n: A) -> u64 {
29
28
x = f ( x) ;
30
29
y = f ( f ( y) ) ;
31
30
let d = {
32
- let _x = n . to_u64 ( x) ;
33
- let _y = n . to_u64 ( y) ;
34
- gcd ( n . modulus ( ) , max ( _x, _y) - min ( _x, _y) )
31
+ let _x = input . to_u64 ( x) ;
32
+ let _y = input . to_u64 ( y) ;
33
+ gcd ( input . modulus ( ) , max ( _x, _y) - min ( _x, _y) )
35
34
} ;
36
- if d == n . modulus ( ) {
35
+ if d == input . modulus ( ) {
37
36
// Failure, retry with a different quadratic
38
37
break ;
39
38
} else if d > 1 {
0 commit comments