Está en la página 1de 2

int factorial(int number) { int factor=1; if(number == 0) return 1; else { for(int i = number ; i>=1 ; i--) // contoh: 3; 3>=1 ya;

3-1=2 { factor = factor*i; // contoh: 1=1*3 } return factor; } } int combination(int x, int y) { int result; result = (factorial(x)/(factorial(y)*factorial(x-y))); return result; } void polycetak(int a, int b, int n, int temp2) { int temp; static int k = 0; printf("%d(a^%d*b^%d)", combination(n, k), temp2, k); k++; temp = n-k; if(k<=n) { printf(" + "); polycetak(a, b, n, temp); } } void polycetak2(int a, int b, int n, int temp2) { int temp; static int k = 0; int x = (a^temp2)*(b^k); printf("%d(%d)", combination(n, k), x); k++; temp = n-k; if(k<=n) { printf(" + "); polycetak2(a, b, n, temp); } }int factorial(int number) { int factor=1; if(number == 0) return 1; else { for(int i = number ; i>=1 ; i--) // contoh: 3; 3>=1 ya; 3-1=2 {

factor = factor*i; // contoh: 1=1*3 } return factor; } } int combination(int x, int y) { int result; result = (factorial(x)/(factorial(y)*factorial(x-y))); return result; } void polycetak(int a, int b, int n, int temp2) { int temp; static int k = 0; printf("%d(a^%d*b^%d)", combination(n, k), temp2, k); k++; temp = n-k; if(k<=n) { printf(" + "); polycetak(a, b, n, temp); } } void polycetak2(int a, int b, int n, int temp2) { int temp; static int k = 0; int x = (a^temp2)*(b^k); printf("%d(%d)", combination(n, k), x); k++; temp = n-k; if(k<=n) { printf(" + "); polycetak2(a, b, n, temp); } }

También podría gustarte