0% found this document useful (0 votes)
7 views1 page

Factorial Series Sum by Function

Uploaded by

aowladhussain99
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

Factorial Series Sum by Function

Uploaded by

aowladhussain99
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

#include <stdio.

h>

// Function to calculate factorial of a number


int fact(int n) {
int f = 1;
for (int i = 1; i <= n; i++) {
f *= i; // Calculate factorial
}
return f;
}

int main() {
int n;
long long int sum = 0;

printf("Enter a number to calculate the sum of the series: ");


scanf("%d", &n);

for (int i = 1; i <= n; i++) {


sum += fact(i) / i;

// Print the result


printf("\nThe sum of the series 1!/1 + 2!/2 + ... + %d!/%d is: %lld\n", n,
n, sum);

return 0;
}

You might also like