Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- double fact(long n){
- if(n == 1 || n==0){
- return(1);
- }
- else{
- return(n*fact(n-1));
- }
- /* else{
- for(int i = 1; i <= n; ++i) {
- n = n*i;
- }
- return(n);
- } */
- }
- long comb (int g, int e){
- int x;
- if(g>e) cout<<"deu ruim";
- x = fact(g)/(fact(e)*fact(g-e));
- return(x);
- }
- void pir(int j){
- for(int i = 1; i<=j ; i++){
- for(int k = 1; k <= i; k++){
- cout<< fact(j)/(fact(i)*fact(j-i)) <<"\t";
- }
- cout<<"\n";
- }
- }
- int main(){
- pir(5);
- return(0);
- }
Add Comment
Please, Sign In to add comment