This page is READ-ONLY. It is generated from the old site.
All timestamps are relative to 2013 (when this page is generated).
If you are looking for TeX support, please go to VietTUG.org

## Problem #991

### Một phiên bản khác của tam giác Pascal

Status: New Start Date: 04-11-2012
Priority: Normal Due date:
Assigned to: - % Done:

0%

Category: -
Target version: -
Resolution:
Votes: 0/0

Description

Có lần tôi đã giới thiệu tam giác Pascal có dạng một tam giác cân. Ở đoạn mã này, là tam giác vuông cân.

\documentclass{article}
\usepackage{tikz}
\makeatletter
\newcommand\binomialCoefficient2{%
% Store values
\[email protected]@counta=#1% n
\[email protected]@countb=#2% k

% Take advantage of symmetry if k > n - k
\[email protected]@countc=\[email protected]@counta

\advance\[email protected]@countc by-\[email protected]@countb%
\ifnum\[email protected]@countb>\[email protected]@countc%
\[email protected]@countb=\[email protected]@countc%
\fi%

% Recursively compute the coefficients
\[email protected]@countc=1
will hold the result
\[email protected]@countd=0% counter
\pgfmathloop% c -> c*(n-i)/(i+1) for i=0,...,k-1
\ifnum\[email protected]@countd \multiply\[email protected]@countc by\[email protected]@counta%
\advance\[email protected]@counta by-1%
\advance\[email protected]@countd by1%
\divide\[email protected]@countc by\[email protected]@countd%
\repeatpgfmathloop%
\the\[email protected]@countc%
}
\makeatother

\begin{document}
\begin{tikzpicture}
\foreach \n in {0,...,15} {
\foreach \k in {0,...,\n} {
\node at (\k,-\n) {$\binomialCoefficient{\n}{\k}$};
}
}
\end{tikzpicture}

\end{document}