Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to write the factorial of N in C language
How to write the factorial of N in C language

1. Open the visual C++ software, create a new task, left-click the file, and select C++ source file:

2. Enter the code, first introduce the c language standard library "# include < stdio.h>", and then write the program in the main function. In fact, the factorial of n is the accumulation from 1 to n. Just write a for loop to continuously calculate the product from 1 to n:

< p>3. After the writing is completed, click the compile button on the left. After the compilation is completed, click the button on the right to run the program:

4. After running the software, Debug will generate an exe factorial executable program, open it Enter 5 here and press Enter to calculate the factorial of 5. At this point, you have completed writing the program: