\documentclass[10pt,landscape,a4paper]{article}
\usepackage{fancyvrb,amsmath}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage[table,svgnames]{xcolor}
\usepackage[margin=1cm]{geometry}
\usepackage[colorlinks=true]{hyperref}
\usepackage{fourier,nopageno,slashbox}

%%%% un peu de giac/xcas

\makeatletter
\newcommand{\executGiacmp}[1]{
\immediate\write18{giac  <#1 } }
\makeatother


\begin{VerbatimOut}{XCASPascalTriangle.cxx}
PascalTriangle(L):={
  local n, c;
  n:=L[0];
  c:=n+2;
  T:="\\begin{tabular}{*{"+c+"}{|c}|}
       \\hline \\backslashbox{$n$}{$k$} ";
  for(colonne:=0; colonne<=n; colonne:=colonne+1) 
  {
  	T:=T+" & \\cellcolor{Moccasin}"+colonne;
  }
  T:=T+"\\\\\\hline";
  for(ligne:=1; ligne<=n; ligne:=ligne+1)
  {
  	for(colonne:=0; colonne<=c-1; colonne:=colonne+1) 
  	{
	  	if(colonne==0)
	  	then{T:=T+"\\cellcolor{Moccasin}"+ligne+"&"}
	  	else
	  	{
	  		I:=factorial(ligne)/(factorial(colonne-1)*factorial(ligne-colonne+1));
	  		if(colonne==c-1)
	  		then{
	  			if(I==0)
	  			then{T:=T+"\\\\\\hline"}
	  			else{T:=T+latex(I)+"\\\\\\hline"}
	  		}
	  		else{
	  			if(I==0)
	  			then{T:=T+"&"}
	  			else{T:=T+latex(I)+"&"}
	  		}
	  	}
	 	}
  }
  T:=T+"\\end{tabular}";
}
:;
\end{VerbatimOut}

\begin{VerbatimOut}{XCASPascalTriangle.giac}
maple_mode(0);
read("XCASPascalTriangle.cxx");
Sortie:=fopen("XCASPascalTriangle.tex");
donnees:=read("XCASPascalTriangle.user");
Resultat:=cat("PascalTriangle(",donnees);
Resultat:=cat(Resultat,");");
Resultat:=expr(Resultat);
fprint(Sortie,Unquoted,Resultat);
fclose(Sortie);
\end{VerbatimOut}

\newenvironment{PascalTriangle}
{\VerbatimEnvironment\begin{VerbatimOut}{XCASPascalTriangle.user}}
{\end{VerbatimOut}
           \executGiacmp{XCASPascalTriangle.giac}

\input{XCASPascalTriangle}
}


\begin{document}

\begin{center}
\begin{Large}\bfseries \textcolor{DarkRed}{Triangle de PASCAL}\end{Large}\\
\url{http://www.mathweb.fr}

\arrayrulecolor{DarkRed}

\[ \binom{n}{k}=\frac{n!}{k!(n-k)!}\]

\bigskip

\begin{PascalTriangle}
20
\end{PascalTriangle}
\end{center}

\bigskip

Ces nombres représentent les coefficients du développement de $(a+b)^n$ (binôme de Newton).

\paragraph*{Exemple :} \[(a+b)^7 =  a^7+7a^6b+21a^5b^2+35a^4b^3+35a^3b^4+21a^2b^5+7ab^6+b^7\]
\end{document}
