Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Programme to calculate Combination

// Java program To calculate
// The Value Of nCr
class GFG {
 
static int nCr(int n, int r)
{
    return fact(n) / (fact(r) *
                  fact(n - r));
}
 
// Returns factorial of n
static int fact(int n)
{
    int res = 1;
    for (int i = 2; i <= n; i++)
        res = res * i;
    return res;
}
 
// Driver code
public static void main(String[] args)
{
    int n = 5, r = 3;
    System.out.println(nCr(n, r));
}
}
 
// This code is Contributed by
// Smitha Dinesh Semwal.
Comment

PREVIOUS NEXT
Code Example
Java :: if checkbox checked java 
Java :: deserialize list jackson 
Java :: currency formatter java 
Java :: spring security logging 
Java :: how to get string input line in java 
Java :: regex s+ 
Java :: how to create hashmap 
Java :: maximum arrays size in java 
Java :: java for item in array 
Java :: creating an array list in java 
Java :: Arraylist in java by dc 
Java :: jdbc dependency 
Java :: add recyclerview in fragment 
Java :: pop back stack fragment android 
Java :: java return new instance of generic type 
Java :: how to call super onbackpressed in fragment 
Java :: mvn spring boot ends when closing vm 
Java :: what are parameters in java 
Java :: java foreach method 
Java :: transparent card background android 
Java :: compress a directory in java 
Java :: java list remove 
Java :: protobuf java gradle mvn 
Java :: java change frame border 
Java :: how to sort arraylist in java 
Java :: android press back 2 times to exit 
Java :: final method and abstract method 
Java :: java background color 
Java :: measure view height android 
Java :: java continue statement 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =