Clarified docs for calc.perm,rem,quo (#2408)

This commit is contained in:
Joseph Wilson 2023-10-19 21:12:28 +13:00 committed by GitHub
parent 01b14ff316
commit 06ba535c45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -445,8 +445,12 @@ pub fn fact(
/// Calculates a permutation. /// Calculates a permutation.
/// ///
/// Returns the `k`-permutation of `n`, or the number of ways to choose `k`
/// items from a set of `n` with regard to order.
///
/// ```example /// ```example
/// #calc.perm(10, 5) /// $ "perm"(n, k) &= n!/((n - k)!) \
/// "perm"(5, 3) &= #calc.perm(5, 3) $
/// ``` /// ```
#[func(title = "Permutation")] #[func(title = "Permutation")]
pub fn perm( pub fn perm(
@ -482,6 +486,9 @@ fn fact_impl(start: u64, end: u64) -> Option<i64> {
/// Calculates a binomial coefficient. /// Calculates a binomial coefficient.
/// ///
/// Returns the `k`-combination `n`, or the number of ways to choose `k`
/// items from a set of `n` without regard to order.
///
/// ```example /// ```example
/// #calc.binom(10, 5) /// #calc.binom(10, 5)
/// ``` /// ```
@ -779,6 +786,9 @@ pub fn odd(
/// Calculates the remainder of two numbers. /// Calculates the remainder of two numbers.
/// ///
/// The value `calc.rem(x, y)` always has the same sign as `x`, and is smaller
/// in magnitude than `y`.
///
/// ```example /// ```example
/// #calc.rem(20, 6) \ /// #calc.rem(20, 6) \
/// #calc.rem(1.75, 0.5) /// #calc.rem(1.75, 0.5)
@ -796,11 +806,12 @@ pub fn rem(
Ok(dividend.apply2(divisor.v, Rem::rem, Rem::rem)) Ok(dividend.apply2(divisor.v, Rem::rem, Rem::rem))
} }
/// Calculates the quotient of two numbers. /// Calculates the quotient (floored division) of two numbers.
/// ///
/// ```example /// ```example
/// #calc.quo(14, 5) \ /// $ "quo"(a, b) &= floor(a/b) \
/// #calc.quo(3.46, 0.5) /// "quo"(14, 5) &= #calc.quo(14, 5) \
/// "quo"(3.46, 0.5) &= #calc.quo(3.46, 0.5) $
/// ``` /// ```
#[func(title = "Quotient")] #[func(title = "Quotient")]
pub fn quo( pub fn quo(