In [1]:
import numpy as np
In [2]:
N = 10000
MOD = 10 ** 10
In [3]:
comb = np.zeros((N+1,N+1),dtype=np.int64)
In [4]:
comb[:,0] = 1
In [5]:
%%time
for n in range(1,N+1):
    comb[n, 1:n+1] = comb[n-1, :n] + comb[n-1, 1:n+1]
    comb[n] %= MOD
Wall time: 1.05 s
In [6]:
comb[:10, :10]
Out[6]:
array([[  1,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  1,   1,   0,   0,   0,   0,   0,   0,   0,   0],
       [  1,   2,   1,   0,   0,   0,   0,   0,   0,   0],
       [  1,   3,   3,   1,   0,   0,   0,   0,   0,   0],
       [  1,   4,   6,   4,   1,   0,   0,   0,   0,   0],
       [  1,   5,  10,  10,   5,   1,   0,   0,   0,   0],
       [  1,   6,  15,  20,  15,   6,   1,   0,   0,   0],
       [  1,   7,  21,  35,  35,  21,   7,   1,   0,   0],
       [  1,   8,  28,  56,  70,  56,  28,   8,   1,   0],
       [  1,   9,  36,  84, 126, 126,  84,  36,   9,   1]], dtype=int64)