Skip to content

p036.c

Problem Statement

sum = a + (a^2)/2 + (a^3)/3 + ... + (a^n)/n

Metadata

Property Detail
Author Amit Dutta (amitdutta4255@gmail.com)
License MIT

Actions

Raw View on GitHub

💡 You can print or save this file by opening Raw and using your browser.

Source Code

#include <stdio.h>
#include <math.h>

int main()
{
    double a, sum = 0;
    int n, i;
    printf("Enter value for a and n : ");
    scanf("%lf %d", &a, &n);
    for (i = 1; i <= n; i++)
        sum += pow(a, i) / i;
    printf("\nSum = %g", sum);
    return 0;
}