Program to Find Sum of Series 1^11+2^22+3^33...+n^nn

Python Program to Find Sum of Series 1^1/1+2^2/2+3^3/3…+n^n/n

In the previous article, we have discussed Python Program to Find Sum of Series 1/2!+2/3!+3/5!+…..N/(N+1)!
Given a number N and the task is to find the sum of series (1^1/1+2^2/2+3^3/3…+N^N/N) till the given number N in Python.

Examples:

Example1:

Input:

Given Number (Limit) = 4

Output:

The above series sum till the given number N{ 4 } =  76.0

Example2:

Input:

Given Number (Limit) = 9

Output:

The above series sum till the given number N{ 9 } =  45269999.0

Program to Find Sum of Series 1^1/1+2^2/2+3^3/3…+n^n/n in Python

Below are the ways to find the sum of series (1^1/1+2^2/2+3^3/3…+N^N/N) till the given number N in Python:

Method #1: Using For Loop (Static Input)

Approach:

  • Import math module using the import keyword.
  • Give the number N (Limit) as static input and store it in a variable.
  • Take a variable to say rsltseries_summ and initialize its value to 0.0 (Floating point number).
  • Loop from 1 to the given number using the for loop.
  • Inside the loop, calculate the value of the iterator raised to the power itself and divided by the iterator value using the pow() function.
  • Store it in another variable.
  • Add the above result to the rsltseries_summ and store it in the same variable.
  • Print the sum of series till the given number N.
  • The Exit of the Program.

Below is the implementation:

# Import math module using the import keyword.
import math
# Give the number N(limit) as static input and store it in a variable.
gvn_numb = 4
# Take a variable to say rsltseries_summ and initialize its value to 0.0
# (Floating point number)
rsltseries_summ = 0.0
# Loop from 1 to the given number using the for loop.
for itr in range(1, gvn_numb+1):
        # Inside the loop, calculate the value of the iterator raised to the power itself and
        # divided by the iterator value using the pow() function.
        # Store it in another variable.
    a = pow(itr, itr) / itr
    # Add the above result to the rsltseries_summ and store it in the same variable.
    rsltseries_summ += a
# Print the sum of series till the given number N.
print(
    "The above series sum till the given number N{", gvn_numb, "} = ", rsltseries_summ)

Output:

The above series sum till the given number N{ 4 } =  76.0

Method #2: Using For loop (User Input)

Approach:

  • Import math module using the import keyword.
  • Give the number N (Limit) as user input using the int(input()) function and store it in a variable.
  • Take a variable to say rsltseries_summ and initialize its value to 0.0 (Floating point number).
  • Loop from 1 to the given number using the for loop.
  • Inside the loop, calculate the value of the iterator raised to the power itself and divided by the iterator value using the pow() function.
  • Store it in another variable.
  • Add the above result to the rsltseries_summ and store it in the same variable.
  • Print the sum of series till the given number N.
  • The Exit of the Program.

Below is the implementation:

# Import math module using the import keyword.
import math
# Give the number N (Limit) as user input using the int(input()) function and 
# store it in a variable.
gvn_numb = int(input("Enter some Random Number = "))
# Take a variable to say rsltseries_summ and initialize its value to 0.0
# (Floating point number)
rsltseries_summ = 0.0
# Loop from 1 to the given number using the for loop.
for itr in range(1, gvn_numb+1):
    # Inside the loop, calculate the value of the iterator raised to the power itself and
    # divided by the iterator value using the pow() function.
    # Store it in another variable.
    a = pow(itr, itr) / itr
    # Add the above result to the rsltseries_summ and store it in the same variable.
    rsltseries_summ += a
# Print the sum of series till the given number N.
print(
    "The above series sum till the given number N{", gvn_numb, "} = ", rsltseries_summ)

Output:

Enter some Random Number = 9
The above series sum till the given number N{ 9 } = 45269999.0

Explore more Example Python Programs with output and explanation and practice them for your interviews, assignments and stand out from the rest of the crowd.