I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
get GPL
COST (GBP)
this unit 0.50
sub units 0.00
+
0

pascal triangle row

viewed 5714 times and licensed 46 times
Returns the row of order \e n in Pascal's triangle.
Controller: CodeCogs

Interface

C++

Pascal Triangle Row

 
std::vector<int>pascal_triangle_rowintn )
This function generates the row of order n in a Pascal's triangle, based on the following recurrent formula

where

Example 1

#include <codecogs/maths/combinatorics/sequences/pascal_triangle_row.h>
#include <iostream>
int main() {
  std::vector<int> row = Maths::Combinatorics::Sequences::pascal_triangle_row(6);
  std::cout << "Size of row: " << row.size() << std::endl;
  for (int i = 0; i < row.size(); i++)
    std::cout << row[i] << "  ";
  std::cout << std::endl;
  return 0;
}
Output:
Size of row: 7
1  6  15  20  15  6  1

Parameters

nthe order of the row requested

Returns

the row of order n in Pascal's triangle

Authors

Lucian Bentea (August 2005)
Source Code

Source code is available when you agree to a GP Licence or buy a Commercial Licence.

Not a member, then Register with CodeCogs. Already a Member, then Login.