human
Number of subarrays consisting only of Pronic Numbers | Function to check if a number is pronic number or not.
Iterate over the range [ 1 , sqrt ( N ) ].
Return true if N is pronic.
Otherwise , return false.
Function to count the number of subarrays consisting of pronic numbers.
Stores the count of subarrays.
Stores the number of consecutive array elements which are pronic.
Traverse the array.
If i is pronic.
Return the total count.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to number of subarrays consisting only of Pronic Numbers and the other steps required.
 def isPronic ( n ) :
	for i in range ( int ( n ** ( 1 / 2 ) ) + 1 ) :
		if i * ( i + 1 ) == n :
			return True
	return False
def countSub ( arr ) :
	ans = 0
	ispro = 0
	for i in arr :
		if isPronic ( i ) :
			ispro += 1
		else :
			ispro = 0
		ans += ispro
	return ans
arr = [ 5 , 6 , 12 , 3 , 4 ]
print ( countSub ( arr ) )