46 lines
673 B
Plaintext
46 lines
673 B
Plaintext
PascalUT := proc(n::integer)
|
|
local M := Matrix(n,n):
|
|
local i:
|
|
local j:
|
|
M[1,1..n] := 1:
|
|
for j from 2 to n do
|
|
for i from 2 to n do
|
|
M[i,j] := M[i,j-1] + M[i-1,j-1]:
|
|
end:
|
|
end:
|
|
return M:
|
|
end proc:
|
|
|
|
PascalUT(5);
|
|
|
|
PascalLT := proc(n::integer)
|
|
local M := Matrix(n,n):
|
|
local i:
|
|
local j:
|
|
M[1..n,1] := 1:
|
|
for i from 2 to n do
|
|
for j from 2 to n do
|
|
M[i,j] := M[i-1,j] + M[i-1,j-1]:
|
|
end:
|
|
end:
|
|
return M:
|
|
end proc:
|
|
|
|
PascalLT(5);
|
|
|
|
Pascal := proc(n::integer)
|
|
local M := Matrix(n,n):
|
|
local i:
|
|
local j:
|
|
M[1..n,1] := 1:
|
|
M[1,2..n] := 1:
|
|
for i from 2 to n do
|
|
for j from 2 to n do
|
|
M[i,j] := M[i,j-1] + M[i-1,j]:
|
|
end:
|
|
end:
|
|
return M:
|
|
end proc:
|
|
|
|
Pascal(5);
|