def make_mod_tables(self, N, n):
    p = self.mod
    if using_numpy:
        fac = np.arange((n + 1))
        fac[0] = 1
        fac = self.cumprod(fac)
        ifac = np.arange((n + 1), 0, (- 1))
        ifac[0] = pow(int(fac[(- 1)]), (p - 2), p)
        ifac = self.cumprod(ifac)[n::(- 1)]
        n_choose = np.arange((N + 1), (N - n), (- 1))
        n_choose[0] = 1
        n_choose[1:] = ((self.cumprod(n_choose[1:]) * ifac[1:(n + 1)]) % p)
    else:
        fac = ([None] * (n + 1))
        fac[0] = 1
        for i in range(n):
            fac[(i + 1)] = ((fac[i] * (i + 1)) % p)
        ifac = ([None] * (n + 1))
        ifac[n] = pow(fac[n], (p - 2), p)
        for i in range(n, 0, (- 1)):
            ifac[(i - 1)] = ((ifac[i] * i) % p)
        n_choose = ([None] * (n + 1))
        n_choose[0] = 1
        for i in range(n):
            n_choose[(i + 1)] = ((n_choose[i] * (N - i)) % p)
        for i in range((n + 1)):
            n_choose[i] = ((n_choose[i] * ifac[i]) % p)
    (self.fac, self.ifac, self.mod_n_choose) = (fac, ifac, n_choose)
def make_mod_tables(self, N, n):
    p = self.mod
    if using_numpy:
        fac = np.arange((n + 1))
        fac[0] = 1
        fac = self.cumprod(fac)
        ifac = np.arange((n + 1), 0, (- 1))
        ifac[0] = pow(int(fac[(- 1)]), (p - 2), p)
        ifac = self.cumprod(ifac)[n::(- 1)]
        n_choose = np.arange((N + 1), (N - n), (- 1))
        n_choose[0] = 1
        n_choose[1:] = ((self.cumprod(n_choose[1:]) * ifac[1:(n + 1)]) % p)
    else:
        fac = ([None] * (n + 1))
        fac[0] = 1
        for i in range(n):
            fac[(i + 1)] = ((fac[i] * (i + 1)) % p)
        ifac = ([None] * (n + 1))
        ifac[n] = pow(fac[n], (p - 2), p)
        for i in range(n, 0, (- 1)):
            ifac[(i - 1)] = ((ifac[i] * i) % p)
        n_choose = ([None] * (n + 1))
        n_choose[0] = 1
        for i in range(n):
            n_choose[(i + 1)] = ((n_choose[i] * (N - i)) % p)
        for i in range((n + 1)):
            n_choose[i] = ((n_choose[i] * ifac[i]) % p)
    (self.fac, self.ifac, self.mod_n_choose) = (fac, ifac, n_choose)