Professional Documents
Culture Documents
Program
Program
// Method 1
// To find factorial of a number
public int factorial(int a)
{
// Edge case
// Factorial of 0 is unity
if (a == 0)
// Hence return 1
return 1;
// Method 2
// Main driver method
public static void main(String[] arg
{
// Declare and initialize number
// factorial is to be computed
int k = 4;
int a, b;
// Inner loop 1
for (b = 0; b <= k - a; b++)
// Inner loop 2
for (b = 0; b <= a; b++) {
// nCr formula
System.out.print(
" "
+ g.factorial(a)
/ (g.factorial
* g.factori
}