lucproblem009.c (563B)
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 /* Write a program to add first seven terms of the following series using a 8 for loop. 9 1 / 1! + 2 / 2! + 3 / 3! + ... 10 */ 11 /* Let Us C, Chap - 6, Page - 102, Problem 6.2 */ 12 13 #include <stdio.h> 14 #define N 7 // update N here 15 16 int main() 17 { 18 double sum = 0; int fact = 1; 19 for (int i = 1; i <= N; i++) 20 { 21 fact *= i; 22 sum += (double)i / fact; 23 } 24 printf("Sum of the series : %g", sum); 25 return 0; 26 }