function p=PascDemo(n,r,c)

if r==2
	coul=[c 'k' c];
else
	coul='kcyrmgbw';
end

P = diag(ones(1,n));
P(:,1) = ones(n,1);

for j=2:n-1
    for i=j+1:n
        P(i,j) = rem(P(i-1,j) + P(i-1,j-1),r);
    end
end

if nargout==0
	x0=1/2;
	d=1/(2*n);
	y0=1-d;
	x=[-d 0 d 0 -d];
	y=[0 -d 0 d 0];
	for i=1:n
		for j=1:i
			dx=x0+(2*j-i-1)*d;
			fill(x+dx,y0+y,coul(rem(P(i,j)+1,8)+1))
		end
		y0=y0-d;
	end
else
	p=P;
end
