Example: 1+2! + 3! +… + 20! And.

The code is as follows:

/* Program analysis: this program just changes the accumulation to the multiplication */
#include"stdio.h"
main()
{
	float n,s=0,t=1;
	for(n=1; n<=20; n++) { t*=n; s+=t; }printf("1 + 2! + 3! . + 20! =%e\n",s);
}
Copy the code

The output running window is as follows:



Other exercises this week

C programming column

C programming > third week ① ask 1+2! + 3! +… + 20! And.

② give a positive integer not more than 5 digits, the requirements: first, find how many digits it is, two, reverse print out each digit.

C programming > third week ③ a 5 digit, determine whether it is palindrome number. That is, 12321 is a palindrome number, the ones place is the same as the thousands place, and the tens place is the same as the thousands place.

C programming > third week ④ find the prime number within 100.

C programming > third week ⑤ to sort 10 numbers.

⑥ There is an already sorted array. Now enter a number and insert it into the array as usual.

7. Output an array in reverse order.

C programming > third week ⑧ print out Yang Hui triangle (required to print out 10 lines).

The harder you work, the luckier you get! Come on, Aoli!!