def sum_of_series(n):
if n <= 0:
return "N should be a positive integer."
total_sum = 0
for i in range(1, n + 1):
total_sum += 1 / i
return total_sum
try:
N = int(input("Enter a positive integer N: "))
if N <= 0:
print("Please enter a positive integer.")
else:
result = sum_of_series(N)
print(f"The sum of the series for N={N} is: {result:.6f}")
except ValueError:
print("Invalid input! Please enter a positive integer.")
#source code --> clcoding.com
0 Comments:
Post a Comment