[R] Pascal's Triangle

Jason J. Pitt pittjj at uchicago.edu
Wed Dec 28 10:53:16 CET 2011


Oh and also, if it makes sense, you can use n choose k ( 
choose() ) to calculate each element of the triangle if you 
don't want to deal with indicies, addition, etc.

Jason

---- Original message ----
>Date: Wed, 28 Dec 2011 03:42:11 -0600 (CST)
>From: r-help-bounces at r-project.org (on behalf of "Jason J. 
Pitt" <pittjj at uchicago.edu>)
>Subject: Re: [R] Pascal's Triangle  
>To: "Matilda E. Gogos" <matildaelizabethv at gmail.com>, r-
help at r-project.org
>
>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-bounces at r-project.org (on behalf of "Matilda E. 
>Gogos" <matildaelizabethv at gmail.com>)
>>Subject: [R] Pascal's Triangle  
>>To: r-help at r-project.org
>>
>>Hello,
>>
>>Looking to generate Pascal's triangle in R. How do I get 
>started? Thanks,
>>
>>-- 
>>Matilda Gogos
>>matildaelizabethv at gmail.com
>>
>>	[[alternative HTML version deleted]]
>>
>>______________________________________________
>>R-help at 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 at 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.



More information about the R-help mailing list