human
Find permutation of first N natural numbers that satisfies the given condition | Function to find permutation ( p ) of first N natural numbers such that there are exactly K elements of permutation such that GCD ( p [ i ] , i ) > 1.
First place all the numbers in their respective places.
Modify for first n - k integers.
In first index place n - k.
Print the permutation.
Driver code"
Solution in Python:
 ... Write me a code to find permutation of first N natural numbers that satisfies the given condition and the other steps required?
assistant
#Here is code to find permutation of first N natural numbers that satisfies the given condition and the other steps required.
 def Permutation ( n , k ) :
	p = [ 0 for i in range ( n + 1 ) ]
	for i in range ( 1 , n + 1 ) :
		p [ i ] = i
	for i in range ( 1 , n - k ) :
		p [ i + 1 ] = i
	p [ 1 ] = n - k
	for i in range ( 1 , n + 1 ) :
		print ( p [ i ] , end = " ▁ " )
if __name__ == ' _ _ main _ _ ' :
	n = 5
	k = 2
	Permutation ( n , k )