# this code is for x^3 only with any integer limit and any positive value of n.
# a is lower limit
# b is upper limit
# n is number of rectangles
a = int(input("a = "))
b = int(input("b = "))
n = int(input("n = "))
# dx is denoted as x
x = (b-a)/n
#s is sum
s = 0
for i in range(0,n+1):
s = s + (((a + i*x)**3)*(x))
print(s)
Comments
Leave a comment