human
Check if a number can be written as sum of three consecutive integers | function to check if a number can be written as sum of three consecutive integer ..
if n is 0.
if n is positive , increment loop by 1..
if n is negative , decrement loop by 1..
Running loop from 0 to n - 2.
check if sum of three consecutive integer is equal to n ..
Driver Code"
How can the above be solved in Python?
 ... Give me a code to check if a number can be written as sum of three consecutive integers and the other steps required?
assistant
#Here is code to check if a number can be written as sum of three consecutive integers and the other steps required.
 def checksum ( n ) :
	if n == 0 :
		print ( " - 1 ▁ 0 ▁ 1" )
		return 0
	inc = 0
	if n > 0 :
		inc = 1
	else :
		inc = - 1
	for i in range ( 0 , n - 1 , inc ) :
		if i + i + 1 + i + 2 == n :
			print ( i , " ▁ " , i + 1 , " ▁ " , i + 2 )
			return 0
	print ( " - 1" )
n = 6
checksum ( n )