/*
0! = 1 1! = 1 2! = 2 3! = 6 4! = 24
5! = 120 6! = 720 7! = 5040 8! = 40320 9! = 362880
10! = 3.6288e+06 11! = 3.99168e+07 12! = 4.79002e+08 13! = 6.22702e+09 14! = 8.71783e+10
15! = 1.30767e+12 16! = 2.09228e+13 17! = 3.55687e+14 18! = 6.40237e+15 19! = 1.21645e+17
20! = 2.4329e+18 21! = 5.10909e+19 22! = 1.124e+21 23! = 2.5852e+22 24! = 6.20448e+23
25! = 1.55112e+25 26! = 4.03291e+26 27! = 1.08889e+28 28! = 3.04888e+29 29! = 8.84176e+30
30! = 2.65253e+32 31! = 8.22284e+33 32! = 2.63131e+35 33! = 8.68332e+36 34! = 2.95233e+38
35! = 1.03331e+40 36! = 3.71993e+41 37! = 1.37638e+43 38! = 5.23023e+44 39! = 2.03979e+46
40! = 8.15915e+47 41! = 3.34525e+49 42! = 1.40501e+51 43! = 6.04153e+52 44! = 2.65827e+54
45! = 1.19622e+56 46! = 5.50262e+57 47! = 2.58623e+59 48! = 1.24139e+61 49! = 6.08282e+62
50! = 3.04141e+64 51! = 1.55112e+66 52! = 8.06582e+67 53! = 4.27488e+69 54! = 2.30844e+71
55! = 1.26964e+73 56! = 7.10999e+74 57! = 4.05269e+76 58! = 2.35056e+78 59! = 1.38683e+80
60! = 8.32099e+81 61! = 5.0758e+83 62! = 3.147e+85 63! = 1.98261e+87 64! = 1.26887e+89
65! = 8.24765e+90 66! = 5.44345e+92 67! = 3.64711e+94 68! = 2.48004e+96 69! = 1.71122e+98
70! = 1.19786e+100 71! = 8.50479e+101 72! = 6.12345e+103 73! = 4.47012e+105 74! = 3.30789e+107
75! = 2.48091e+109 76! = 1.88549e+111 77! = 1.45183e+113 78! = 1.13243e+115 79! = 8.94618e+116
80! = 7.15695e+118 81! = 5.79713e+120 82! = 4.75364e+122 83! = 3.94552e+124 84! = 3.31424e+126
85! = 2.8171e+128 86! = 2.42271e+130 87! = 2.10776e+132 88! = 1.85483e+134 89! = 1.6508e+136
90! = 1.48572e+138 91! = 1.352e+140 92! = 1.24384e+142 93! = 1.15677e+144 94! = 1.08737e+146
95! = 1.033e+148 96! = 9.91678e+149 97! = 9.61928e+151 98! = 9.42689e+153 99! = 9.33262e+155
*/
#include <iostream>
#include <array>
int main() {
using namespace std;
const int arSize = 100;
array<long double, arSize > arr {1, 1};
for (int i = 2; i < arSize ; i++)
arr[i] = i * arr[i -1];
for ( int i = 0; i < arSize; i++) {
cout << i << "! = " << arr[i] << "\t";
if ((i + 1) % 5 == 0)
cout << "\n";
}
}
打印0~99的阶乘
最新推荐文章于 2019-07-18 10:13:06 发布