# Calcul des coefficients binomiaux : version sequentielle. # INF7440, A04. resource CB() int n, k; getarg(1,n); getarg(2,k); # on suppose k <= n int B[0:n,0:k]; procedure CB_PD() returns int r { for [ i = 0 to n ] { for [ j = 0 to min(i, k) ] { if ( (j == 0) | (j == i) ) { B[i,j] = 1; } else { B[i,j] = B[i-1,j-1] + B[i-1,j]; } } } r = B[n,k]; } write(CB_PD(4,2)); end