P036.c (452B)
1 /* 2 * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 12 Dec 2025 3 * Repo: https://github.com/notamitgamer/bsc 4 * License: MIT 5 */ 6 7 /* sum = a + (a^2)/2 + (a^3)/3 + ... + (a^n)/n */ 8 9 #include <stdio.h> 10 #include <math.h> 11 12 int main() 13 { 14 double a, sum = 0; 15 int n, i; 16 printf("Enter value for a and n : "); 17 scanf("%lf %d", &a, &n); 18 for (i = 1; i <= n; i++) 19 sum += pow(a, i) / i; 20 printf("\nSum = %g", sum); 21 return 0; 22 }