human
Sum of first n odd numbers in O ( 1 ) Complexity | Python3 program to find sum of first n odd numbers.
Returns the sum of first n odd numbers.
Driver Code"
Solution in Python:
assistant
#Here is code to sum of first n odd numbers in O ( 1 ) Complexity and the other steps required.
 def oddSum ( n ) :
	sum = 0
	curr = 1
	i = 0
	while i < n :
		sum = sum + curr
		curr = curr + 2
		i = i + 1
	return sum
n = 20
print ( " ▁ Sum ▁ of ▁ first " , n , " Odd ▁ Numbers ▁ is : ▁ " , oddSum ( n ) )