Advertisements
Advertisements
प्रश्न
Write a program to find the sum of 1 + 1/8 + 1/27......1/n3, where n is the number input by the user.
टिप्पणी लिखिए
Advertisements
उत्तर
Program:
sum = 0
#Getting the number input from the user
n = int(input("Enter the number: "))
for a in range(1,n+1):
#calculating the sum
sum = sum + (1/pow(a,3))
#Sum of the series is
print("The sum of the series is: ",round(sum,2))
OUTPUT:
Enter the number: 5
The sum of the series is: 1.19shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
