human
Check if N can be divided into K consecutive elements with a sum equal to N | Function to find the K consecutive elements with a sum equal to N.
Iterate over [ 2 , INF ].
Store the sum.
If the sum exceeds N then break the loop.
Common difference should be divisible by number of terms.
Print value of i & return.
Print " - 1" if not possible to break N.
Given N.
Function call"
How can the above be solved in Python?
 Write me a code to check if N can be divided into K consecutive elements with a sum equal to N and the other steps required?
assistant
#Here is code to check if N can be divided into K consecutive elements with a sum equal to N and the other steps required.
 def canBreakN ( n ) :
	for i in range ( 2 , n ) :
		m = i * ( i + 1 ) // 2
		if ( m > n ) :
			break
		k = n - m
		if ( k % i ) :
			continue
		print ( i )
		return
	print ( " - 1" )
N = 12
canBreakN ( N )