human
Give me a code to permutations of n things taken r at a time with k things together and the other steps required given the following:
Permutations of n things taken r at a time with k things together | def to find factorial of a number.
def to calculate p ( n , r ).
def to find the number of permutations of n different things taken r at a time with k things grouped together.
Driver code"
Solution in Python:
assistant
#Here is code to permutations of n things taken r at a time with k things together and the other steps required.
 def factorial ( n ) :
	fact = 1 ;
	for i in range ( 2 , n + 1 ) :
		fact = fact * i ;
	return fact ;
def npr ( n , r ) :
	pnr = factorial ( n ) / factorial ( n - r ) ;
	return pnr ;
def countPermutations ( n , r , k ) :
	return int ( factorial ( k ) * ( r - k + 1 ) * npr ( n - k , r - k ) ) ;
n = 8 ;
r = 5 ;
k = 2 ;
print ( countPermutations ( n , r , k ) ) ;