Skip to content

Commit

Permalink
Proper inline code in mod_pow and mod_mul
Browse files Browse the repository at this point in the history
  • Loading branch information
JSorngard committed May 10, 2024
1 parent 168bfff commit 58e7cbe
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/imath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
//! functions in the crate.
/// Returns the largest integer smaller than or equal to `√n`.
///
///
/// # Examples
///
///
/// Basic usage:
/// ```
/// # use const_primes::isqrt;
/// const ISQRT25: u64 = isqrt(25);
/// const ISQRT35: u64 = isqrt(35);
/// const ISQRT36: u64 = isqrt(36);
///
///
/// assert_eq!(ISQRT25, 5);
/// assert_eq!(ISQRT35, 5);
/// assert_eq!(ISQRT36, 6);
Expand All @@ -31,7 +31,7 @@ pub const fn isqrt(n: u64) -> u64 {
}
}

/// Calculates `(base ^ exp) mod modulo` without overflow.
/// Calculates (`base` ^ `exp`) mod `modulo` without overflow.
#[must_use]
pub const fn mod_pow(mut base: u64, mut exp: u64, modulo: u64) -> u64 {
let mut res = 1;
Expand All @@ -49,7 +49,7 @@ pub const fn mod_pow(mut base: u64, mut exp: u64, modulo: u64) -> u64 {
res
}

/// Calculates `(a * b) mod modulo` without overflow.
/// Calculates (`a` * `b`) mod `modulo` without overflow.
#[must_use]
pub const fn mod_mul(a: u64, b: u64, modulo: u64) -> u64 {
((a as u128 * b as u128) % modulo as u128) as u64
Expand Down

0 comments on commit 58e7cbe

Please sign in to comment.