Hi Matilda,

My ignorance of the mathematical properties of Pascal's 
Triangle might make me overlook a much easier way to do this, 
but my first brute force thought was to use a list to store 
each level of the triangle (i.e. a list of vectors). You can 
then use the values of the previous level to calculate the 
values of the next level.

Then it should just be a matter of formatting using spaces or 
tabs and printing each level (vector) in the list. There may 
be some nuances to this depending how you want it to look, but 
nothing a little trial and error and Googling can't solve.

HTH,

Jason

---- Original message ----
>Date: Tue, 27 Dec 2011 23:14:27 -0500
>From: r-help-boun...@r-project.org (on behalf of "Matilda E. 
Gogos" <matildaelizabe...@gmail.com>)
>Subject: [R] Pascal's Triangle  
>To: r-help@r-project.org
>
>Hello,
>
>Looking to generate Pascal's triangle in R. How do I get 
started? Thanks,
>
>-- 
>Matilda Gogos
>matildaelizabe...@gmail.com
>
>       [[alternative HTML version deleted]]
>
>______________________________________________
>R-help@r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-
project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible 
code.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to