human
Find if given number is sum of first n natural numbers | Function to find no . of elements to be added from 1 to get n.
Start adding numbers from 1.
If sum becomes equal to s return n.
Driver code"
Solution in Python:
assistant
#Here is code to find if given number is sum of first n natural numbers and the other steps required.
 def findS ( s ) :
	_sum = 0
	n = 1
	while ( _sum < s ) :
		_sum += n
		n += 1
	n -= 1
	if _sum == s :
		return n
	return - 1
s = 15
n = findS ( s )
if n == - 1 :
	print ( " - 1" )
else :
	print ( n )