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

Implementations on Foreign Types§

source§

impl LinearFloorSum for u16

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 i128

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 usize

source§

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

source§

impl LinearFloorSum for i8

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 i32

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 isize

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 u32

source§

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

Implementors§