954,505 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Pascals triangle (Functions)

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
using std::cout ;
#include
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

sean25hun
Newbie Poster
9 posts since Jan 2007
Reputation Points: 10
Solved Threads: 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?

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

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

sean25hun
Newbie Poster
9 posts since Jan 2007
Reputation Points: 10
Solved Threads: 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:

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You