Skip to main content

LinearFloorSum

Trait LinearFloorSum 

Source
pub trait LinearFloorSum {
    // Required method
    fn linear_floor_sum(self, m: Self, a: Self, b: Self) -> Self;
}
Expand description

$ \sum_{i=0}^{n-1} \left\lfloor\frac{ai+b}{m}\right\rfloor. $

§Requirements

  • $n \ge 0$
  • $m \gt 0$

§Idea

あとで書く。

§See also

§Examples

use nekolib::math::LinearFloorSum;

assert_eq!(4_u128.linear_floor_sum(10, 6, 3), 3);
assert_eq!(6_u128.linear_floor_sum(5, 4, 3), 13);
assert_eq!(1_u128.linear_floor_sum(1, 0, 0), 0);
assert_eq!(31415_u128.linear_floor_sum(92653, 58979, 32384), 314095480);
assert_eq!(
    1000000000_u128.linear_floor_sum(1000000000, 999999999, 999999999),
    499999999500000000
);
assert_eq!(14_i128.linear_floor_sum(23, -7, -39), -58);

Required Methods§

Source

fn linear_floor_sum(self, m: Self, a: Self, b: Self) -> Self

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl LinearFloorSum for i8

Source§

fn linear_floor_sum(self, m: Self, a: Self, b: Self) -> Self

Source§

impl LinearFloorSum for i16

Source§

fn linear_floor_sum(self, m: Self, a: Self, b: Self) -> Self

Source§

impl LinearFloorSum for i32

Source§

fn linear_floor_sum(self, m: Self, a: Self, b: Self) -> Self

Source§

impl LinearFloorSum for i64

Source§

fn linear_floor_sum(self, m: Self, a: Self, b: Self) -> Self

Source§

impl LinearFloorSum for i128

Source§

fn linear_floor_sum(self, m: Self, a: Self, b: Self) -> Self

Source§

impl LinearFloorSum for isize

Source§

fn linear_floor_sum(self, m: Self, a: Self, b: Self) -> Self

Source§

impl LinearFloorSum for u8

Source§

fn linear_floor_sum(self, m: Self, a: Self, b: Self) -> Self

Source§

impl LinearFloorSum for u16

Source§

fn linear_floor_sum(self, m: Self, a: Self, b: Self) -> Self

Source§

impl LinearFloorSum for u32

Source§

fn linear_floor_sum(self, m: Self, a: Self, b: Self) -> Self

Source§

impl LinearFloorSum for u64

Source§

fn linear_floor_sum(self, m: Self, a: Self, b: Self) -> Self

Source§

impl LinearFloorSum for u128

Source§

fn linear_floor_sum(self, m: Self, a: Self, b: Self) -> Self

Source§

impl LinearFloorSum for usize

Source§

fn linear_floor_sum(self, m: Self, a: Self, b: Self) -> Self

Implementors§