Part of the series

Several example codes

~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(k+1)(k+2) / (n+k)(n+k+1)(n+k+2)] for k from 1 to n
Each term involves a product of three consecutive integers in both numerator and denominator.


Python Code:


def compute_series(n: int) -> float:
    total = 0.0
    for k in range(1, n + 1):
        numerator = k * (k + 1) * (k + 2)
        denominator = (n + k) * (n + k + 1) * (n + k + 2)
        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 = 3):


Series result is: 0.317460

Written & researched by Dr. Shahin Siami