Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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

combinations



from itertools import permutations
from itertools import combinations
p = permutations([1,2,4]) # or  permutations([1, 2, 3], 2)
for i in p:
    print(i)
c = combinations([1,2,3],2)
for j in c:
    print(j)
    
    
Comment

PREVIOUS NEXT
Code Example
Python :: importing a python file from another folder 
Python :: what is an object in python 
Python :: sum() python 
Python :: python3 conditional with boolean 
Python :: sudo in python 
Python :: pipeline model coefficients 
Python :: python cointegration 
Python :: code pandas from url 
Python :: python identify image mode 
Python :: Reducing noise on Data 
Python :: python system performance 
Python :: check if element is in list 
Python :: pass query params django template 
Python :: number length python 
Python :: python remove specific character from string 
Python :: start ipython with any version 
Python :: mid point circle drawing 
Python :: assignment 6.5 python for everybody 
Python :: Removing Elements from Python Dictionary Using del keyword 
Python :: pandas select multiple columns 
Python :: theme_use() tkinter theme usage 
Python :: looping through the list 
Python :: pandas trim string of all cells 
Python :: python all list items to lower case 
Python :: Setting spacing (minor) between ticks in matplotlib 
Python :: python unittest multiple test cases 
Python :: override get_queryset django with url parameters 
Python :: how to backspace in python 
Python :: .add_prefix to certain columns python 
Python :: pandas make currency with commas 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =