diff --git a/vm/src/stdlib/math.rs b/vm/src/stdlib/math.rs index 9be54c90e..a4ccd1fef 100644 --- a/vm/src/stdlib/math.rs +++ b/vm/src/stdlib/math.rs @@ -237,13 +237,12 @@ fn math_gcd(a: PyIntRef, b: PyIntRef, vm: &VirtualMachine) -> PyResult { fn math_factorial(vm: &VirtualMachine, args: PyFuncArgs) -> PyResult { arg_check!(vm, args, required = [(value, None)]); let value = objint::get_value(value); - if value < &BigInt::zero() { - return Err(vm.new_value_error(format!("factorial() not defined for negative values"))) - } else if value <= &BigInt::one() { - return Ok(vm.ctx.new_int(BigInt::from(1u64))) + if *value < BigInt::zero() { + return Err(vm.new_value_error("factorial() not defined for negative values".to_string())); + } else if *value <= BigInt::one() { + return Ok(vm.ctx.new_int(BigInt::from(1u64))); } - let ret: BigInt = - num_iter::range_inclusive(BigInt::from(1u64), BigInt::from(value.clone())).product(); + let ret: BigInt = num_iter::range_inclusive(BigInt::from(1u64), value.clone()).product(); Ok(vm.ctx.new_int(ret)) }