Catalan numbers/Pascal's triangle: Difference between revisions
Catalan numbers/Pascal's triangle (view source)
Revision as of 18:15, 13 November 2014
, 9 years agoAdd Batch File section
PatGarrett (talk | contribs) |
PatGarrett (talk | contribs) (Add Batch File section) |
||
Line 173:
1 2 5 14 42 132 429 1430 4862 16796 58786 208012 742900 2674440 9694845
</pre>
=={{header|Batch File}}==
<lang dos>
@echo off
setlocal ENABLEDELAYEDEXPANSION
rem t(0:n+1)
set n=15
set /A nn=n+1
for /L %%i in (0,1,%nn%) do set t.%%i=0
set t.1=1
for /L %%i in (1,1,%n%) do (
set /A ip=%%i+1
for /L %%j in (%%i,-1,1) do (
set /A jm=%%j-1
set /A t.%%j=t.%%j+t.!jm!
)
set /A t.!ip!=t.%%i
for /L %%j in (!ip!,-1,1) do (
set /A jm=%%j-1
set /A t.%%j=t.%%j+t.!jm!
)
set /A ci=t.!ip!-t.%%i
rem echo %%i !ci!
echo !ci!
)
)
pause
</lang>
{{Out}}
<pre style="height:20ex">
1
2
5
14
42
132
429
1430
4862
16796
58786
208012
742900
2674440
9694845
</pre>
=={{header|C++}}==
|