Pascal's Pyramid and Higher Dimensions
Ruby, 181

def P(a)a.min&lt;0?0:a.max&lt;1?1:(b=a*1;t=k=0;b.map{b[k]-=1;k+=1;t+=P(b)};t)end
def d(n,a)print n&gt;1?((0..a[-1]).map{|i|d(n-1,a+[i])};&quot;\n&quot;):&quot;#{P(a)} &quot;end
d(ARGV[0].to_i,[ARGV[1].to_i])

The first approach using the following recursive formula
P(...,-1,...) = 0
P(0,0,...,0) = 1
P(a,b,c,....) = P(a-1,b,c,...) + P(a-1,b-1,c,...) + P(a-1,b-1,c-1,...) + ...

and then printing row P(R,...).
The output is triangle-like - for pascal 4 2 it looks like
1 

3 
3 3 

3 
6 6 
3 6 3 

1 
3 3 
3 6 3 
1 3 3 1