C language calculates the sum of factorials from 1 to n

王林
Release: 2020-05-11 10:17:04
Original
16815 people have browsed it

C language calculates the sum of factorials from 1 to n

Write the header file

#include<stdio.h>
Copy after login

Write the main function.

C language calculates the sum of factorials from 1 to n

#Define sum in the main function using long long, and the defined n is the final factorial number you require.

C language calculates the sum of factorials from 1 to n

Then use a for loop to find the sum of factorials of 1 2! .... n!

C language calculates the sum of factorials from 1 to n

Test whether Correct, when I enter 5, the result is as follows:

C language calculates the sum of factorials from 1 to n

Recommended tutorial: c language tutorial

The above is the detailed content of C language calculates the sum of factorials from 1 to n. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template