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

>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?

ya ive done that in my code havent i ??????

>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:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.