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 + k! / k²] for k from 1 to n
It uses math.sqrt and math.factorial for accurate computation.


Python Code:


import math

def compute_series(n: int) -> float:
    total = 0.0
    for k in range(1, n + 1):
        root_term = math.sqrt(k) / k
        factorial_term = math.factorial(k) / (k ** 2)
        total += root_term + factorial_term
    return total

# Read input from user
n = int(input("Enter value for n: "))
result = compute_series(n)
print(f"Series result is: {result:.4f}")

Sample Output (input: n = 3):


Series result is: 3.6111

Written & researched by Dr. Shahin Siami