C Exercise Example 25
100 cases of classic C language
Title: Demand 1 + 2 + 3 + ... + 20 and!!!.
Program Analysis: This program just multiply accumulate become tired.
Source Code:
// Created by www.w3big.com on 15/11/9. // Copyright © 2015年 本教程. All rights reserved. // #include <stdio.h> int main() { int i; long double sum,mix; sum=0,mix=1; for(i=1;i<=20;i++) { mix=mix*i; sum=sum+mix; } printf("%Lf\n",sum); }
The above example output is:
2561327494111820313.000000