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 :: how to import from parent directory 
Python :: python convert from float to decimal 
Python :: django filter by date range 
Python :: python get parent directory 
Python :: create a blank image cv2 
Python :: web scraping python beautifulsoup 
Python :: pyside 
Python :: save list to dataframe pandas 
Python :: pyspark dropna in one column 
Python :: how to convert binary to text in python 
Python :: print pretty in python 
Python :: how to do swapping in python without 
Python :: python how to make notepad 
Python :: python replace by dictionary 
Python :: cryptography python 
Python :: add x=y line to scatter plot python 
Python :: python socket recv set timeout 
Python :: import numpy financial python 
Python :: selenium get cookies python 
Python :: run python notepad++ 
Python :: how to remove a tuple from a list python 
Python :: SystemError: tile cannot extend outside image 
Python :: python convert a list to dict 
Python :: how to add window background in pyqt5 
Python :: add one row to dataframe 
Python :: python except print error type 
Python :: python string indexing 
Python :: takes 1 positional argument but 2 were given python 
Python :: python email 
Python :: how to convert all items in a list to integer python 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =