recent

sum of power series

 sum of power series
(1^1) + (2^2) + (3^3) + (4^4) + (5^5) + ... + (n^n)
 

#include<stdio.h>
long power(int x, int y)
{
    long j, pow=1;
    for(j=1;j<=y;j++)
    {
        pow=pow*x;
    }
    return pow;
}

int main()
{
    long j,n,sum=0;
    n=5;
    for(j=1;j<=n;j++)
    {
        sum=sum+power(j,j);
    }
    printf("Sum: %d",sum);
}
Powered by Blogger.