Series Pattern Program for (1^1)/1 + (2^2)/2 + (3^3)/3 + (4^4)/4 + … + (n^n)/n

 

Series Pattern Program for (1^1)/1 + (2^2)/2 + (3^3)/3 + (4^4)/4 + … + (n^n)/n in Python, C, C++ and Java

This article discusses, how to write a prorgram to solve Series Pattern Program for (1^1)/1 + (2^2)/2 + (3^3)/3 + (4^4)/4 + … + (n^n)/n series in python, C, C++ and Java.

Problem Definition

Write a prorgram to solve Series Pattern Program for (1^1)/1 + (2^2)/2 + (3^3)/3 + (4^4)/4 + … + (n^n)/n series in python, C, C++ and Java.

Sample input and Output:

Enter the value of n: 4 

Sum is: 76

Source code to solve the series pattern (1^1)/1 + (2^2)/2 + (3^3)/3 + (4^4)/4 + … + (n^n)/n in python

sum = 0
n = int (input("Enter the value of n:"))
for i in range(1,n+1):
    product = 1
    for j in range(i):
        product = product * i
    sum = sum + (product / i)
print ("Sum is: ", sum))

Source code to solve the series pattern (1^1)/1 + (2^2)/2 + (3^3)/3 + (4^4)/4 + … + (n^n)/n in C

#include <stdio.h>
int main()
{
    int i, j, n, sum = 0, product;
    printf("Enter the value of n:");
    scanf("%d", &n);
    for(i=1; i<=n; i++)
    { 
 	product = 1;
	for (j = 1; j <= i; j++)
	{
	    product = product * i;
	}
	sum = sum + (product / i);
    }
    printf("Sum is: %d", sum);
    return 0;
}

Source code to solve the series pattern (1^1)/1 + (2^2)/2 + (3^3)/3 + (4^4)/4 + … + (n^n)/n in CPP (C++)

#include <iostream>
using namespace std;
int main()
{
    int i, j, n, sum = 0, product;
    cout <<"Enter the value of n:";
    cin >> n;
    for(i=1; i<=n; i++)
    {  
	product = 1;
	for (j = 1; j <= i; j++)
	{
  	    product = product * i;
	}
	    sum = sum + (product / i);
    }
    cout << "Sum is: "<< sum;
    return 0;
}

Source code to solve the series pattern (1^1)/1 + (2^2)/2 + (3^3)/3 + (4^4)/4 + … + (n^n)/n in Java

import java.util.Scanner;
class Series2
{
    private static Scanner scan;
    public static void main(String[] args)
    {
	int i, j, n, sum = 0, product;
	scan = new Scanner(System.in);
	System.out.println("Enter the value of n:");
	n = scan.nextInt();
	for(i=1;i<=n;i++)
	{ 
	    product  = 1;
	    for (j = 1; j <= i; j++)
	    {
		product = product * i;
	    }
	    sum = sum + (product / i);
	}
	System.out.print("Sum: " + sum);
    }
}

Find Frequently asked Pattern Programs in the interview on:

Star Pattern Programs in Python, C, C++ (CPP) and Java

Series Pattern programs in Python, C, C++ (CPP) and Java

Number / Numeric Pattern programs in Python, C, C++ (CPP) and Java

Alphabet / Character Pattern programs in Python, C, C++ (CPP) and Java

This article discusses, how to write a program to display Series Pattern (1^1)/1 + (2^2)/2 + (3^3)/3 + (4^4)/4 + … + (n^n)/n in Python, C, CPP (C++), and Java programming language with the video tutorials.

Subscribe to our YouTube channel for more videos and like the Facebook page for regular updates.

Leave a Comment

Your email address will not be published. Required fields are marked *

Welcome to VTUPulse.com


Computer Graphics and Image Processing Mini Projects -> Click Here

Download Final Year Project -> Click Here

This will close in 12 seconds