0

Can anyone help me with pascals triangle . I got it to do a factorial number , now it want to display the results in a pyramid.

#include <iostream>
using std::cout ;
#include <iomanip>
using std::setw ;

long int factorial(const int);

int main()
{
long int k = factorial (5) ;
cout << setw(20) << " 5! = " << k << "\n" ;
return 0 ;
}
long int factorial(const int n) {
//cout << "fact(" << n << ") = " ;

long int m ;

if (n==0)
return 1 ;
m = n * factorial (n-1) ;
//cout << m << "\n";
return m ;
}
long int combination(int i, int j){


long int p;
p= factorial(i)/factorail(j)*factorial(i-j);
return p;

}

thnks

2
Contributors
3
Replies
4
Views
10 Years
Discussion Span
Last Post by Narue
0

>I got it to do a factorial number , now it want to display the results in a pyramid
Do you understand how to use factorials to derive an individual number from the pyramid?

0

>ya ive done that in my code havent i ??????
Well, one number does technically count as a pyramid, but I imagine you'll have to do it more than once (maybe in a loop?) to get the desired result. :icon_rolleyes:

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.