human
Count subarrays of atleast size 3 forming a Geometric Progression ( GP ) | Function to count all the subarrays of size at least 3 forming GP.
If array size is less than 3.
Stores the count of subarray.
Stores the count of subarray for each iteration.
Traverse the array.
Check if L [ i ] forms GP.
Otherwise , update count to 0.
Update the final count.
Return the final count.
Driver Code.
Given array arr [ ].
Function Call"
How can the above be solved in Python?
 What is a code to count subarrays of atleast size 3 forming a Geometric Progression ( GP ) and the other steps required?
assistant
#Here is code to count subarrays of atleast size 3 forming a Geometric Progression ( GP ) and the other steps required.
 def numberOfGP ( L , N ) :
	if ( N <= 2 ) :
		return 0
	count = 0
	res = 0
	for i in range ( 2 , N ) :
		if ( L [ i - 1 ] * L [ i - 1 ] == L [ i ] * L [ i - 2 ] ) :
			count += 1
		else :
			count = 0
		res += count
	return res
if __name__ == ' _ _ main _ _ ' :
	arr = [ 1 , 2 , 4 , 8 , 16 , 24 ]
	N = len ( arr )
	print ( numberOfGP ( arr , N ) )