Answer the question
In order to leave comments, you need to log in
Calculate the sum of a series with a given precision?
Hello! Please help me understand what is the problem.
*The same number is constantly displayed without stopping*
The task sounds like this: Given real numbers x, ε (x≠0, ε>0) and an integer n. Calculate with precision ε:
Here is my code:
import math
x = float(input("x ="))
e = float(input("e = "))
n = float(input("n = "))
S = 0
if x != 0 and e > 0:
i = 1
while i <= n:
chlen = math.sqrt(math.fabs(x))/n**3
if S + chlen < e:
S = S + chlen
else:
print(S)
else:
print("попробуйте еще раз")
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question