Python  1.0
Functions
_03d_pascal_rec Namespace Reference

Pascal triangle using factorials. More...

Functions

def factr (n)
 Factorial of n, recursive version. More...
 
def fact (n)
 Factorial of n, non-recursive version. More...
 
def kfact (n, k)
 k factorial of n. More...
 
def pascal (n, k)
 The binomial coefficient, refered as row n, column k. More...
 
def showpascal (n)
 Prints successive rows of Pascal's triangle, from 0 to n. More...
 

Detailed Description

Pascal triangle using factorials.

 0        1
 1       1 1
 2      1 2 1
 3     1 3 3 1
 4    1 4 6 4 1
 5  1 5 10 10 5 1
    0 1 2  3  4 5
 
Author
Paulo Roma
Since
12/04/2009
See also
http://en.wikipedia.org/wiki/Pascal_triangle

Function Documentation

◆ fact()

def _03d_pascal_rec.fact (   n)

Factorial of n, non-recursive version.

The factorial, denoted by n!, is defined for a positive integer, and represents the product of all numbers less than or equal n.

Parameters
nan integer.
Returns
n!
See also
https://docs.python.org/3/library/functools.html?highlight=reduce#functools.reduce

Referenced by factr(), and pascal().

◆ factr()

def _03d_pascal_rec.factr (   n)

Factorial of n, recursive version.

The factorial, denoted by n!, is defined for a positive integer, and represents the product of all numbers less than or equal n.

Parameters
nan integer.
Returns
n!

References fact().

◆ kfact()

def _03d_pascal_rec.kfact (   n,
  k 
)

k factorial of n.

Parameters
nan integer.
k
Returns
n!/(n-k)!

Referenced by pascal().

◆ pascal()

def _03d_pascal_rec.pascal (   n,
  k 
)

The binomial coefficient, refered as row n, column k.

It also represents the number of combinations of n things taken k at a time (called n choose k).

Parameters
nrow.
kcolumn.
Returns
n!/(n-k)!k!

References fact(), and kfact().

Referenced by showpascal().

◆ showpascal()

def _03d_pascal_rec.showpascal (   n)

Prints successive rows of Pascal's triangle, from 0 to n.

Parameters
na positive integer.

References _01d_dec2bin.input, and pascal().