This Python program reads an integer n and computes the result of the following series:
∑ [(√(k + 1) - √k) / √(k² + k)] for k from 2 to n
It uses math.sqrt for accurate computation of square roots.
import math
def compute_series(n: int) -> float:
total = 0.0
for k in range(2, n + 1):
numerator = math.sqrt(k + 1) - math.sqrt(k)
denominator = math.sqrt(k**2 + k)
total += numerator / denominator
return total
# Read input from user
n = int(input("Enter value for n: "))
result = compute_series(n)
print(f"Series result is: {result:.6f}")
Series result is: 0.162278