human
Minimum elements inserted in a sorted array to form an Arithmetic progression | Function to find the greatest common divisor of two numbers.
Function to find the minimum the minimum number of elements required to be inserted into array.
Difference array of consecutive elements of the array.
GCD of the difference array.
Loop to calculate the minimum number of elements required.
Driver Code.
Function calling"
Solution in Python:
 Give me a code to minimum elements inserted in a sorted array to form an Arithmetic progression and the other steps required?
assistant
#Here is code to minimum elements inserted in a sorted array to form an Arithmetic progression and the other steps required.
 def gcdFunc ( a , b ) :
	if ( b == 0 ) :
		return a
	return gcdFunc ( b , a % b )
def findMinimumElements ( a , n ) :
	b = [ 0 ] * ( n - 1 )
	for i in range ( 1 , n ) :
		b [ i - 1 ] = a [ i ] - a [ i - 1 ]
	gcd = b [ 0 ]
	for i in range ( n - 1 ) :
		gcd = gcdFunc ( gcd , b [ i ] )
	ans = 0
	for i in range ( n - 1 ) :
		ans += ( b [ i ] // gcd ) - 1
	return ans
arr1 = [ 1 , 6 , 8 , 10 , 14 , 16 ]
n1 = len ( arr1 )
print ( findMinimumElements ( arr1 , n1 ) )