human
Program to find the sum of the series 1 + x + x ^ 2 + x ^ 3 + . . + x ^ n | Function to find the sum of the series and print N terms of the given series.
First Term.
Loop to print the N terms of the series and find their sum.
Driver code"
Solution in Python:
 Give me a code to program to find the sum of the series 1 + x + x ^ 2 + x ^ 3 +?
assistant
#Here is code to program to find the sum of the series 1 + x + x ^ 2 + x ^ 3 + .
 def sum ( x , n ) :
	total = 1.0
	multi = x
	print ( 1 , end = " ▁ " )
	for i in range ( 1 , n ) :
		total = total + multi
		print ( ' % .1f ' % multi , end = " ▁ " )
		multi = multi * x
	print ( ' ' )
	return total ;
x = 2
n = 5
print ( ' % .2f ' % sum ( x , n ) )