~1 min read • Updated Oct 13, 2025
Program Overview
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.
Python Code:
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}")
Sample Output (input: n = 4):
Series result is: 0.162278
Written & researched by Dr. Shahin Siami