18 std::cout <<
"---- Check 1\t";
19 unsigned int i, number = 10;
21 for (i = 2; i <= number; i++)
24 const char *known_reslt =
"3628800";
27 if (strlen(known_reslt) != result.num_digits()) {
28 std::cerr <<
"Result lengths dont match! " << strlen(known_reslt)
29 <<
" != " << result.num_digits() << std::endl;
33 const size_t N = result.num_digits();
34 for (i = 0; i < N; i++) {
35 if (known_reslt[i] != result.digit_char(i)) {
36 std::cerr << i <<
"^th digit mismatch! " << known_reslt[i]
37 <<
" != " << result.digit_char(i) << std::endl;
42 std::cout <<
"Passed!" << std::endl;
55 std::cout <<
"---- Check 2\t";
56 unsigned int i, number = 100;
58 for (i = 2; i <= number; i++)
61 const char *known_reslt =
62 "9332621544394415268169923885626670049071596826438162146859296389521759"
63 "9993229915608941463976156518286253697920827223758251185210916864000000"
67 if (strlen(known_reslt) != result.num_digits()) {
68 std::cerr <<
"Result lengths dont match! " << strlen(known_reslt)
69 <<
" != " << result.num_digits() << std::endl;
73 const size_t N = result.num_digits();
74 for (i = 0; i < N; i++) {
75 if (known_reslt[i] != result.digit_char(i)) {
76 std::cerr << i <<
"^th digit mismatch! " << known_reslt[i]
77 <<
" != " << result.digit_char(i) << std::endl;
82 std::cout <<
"Passed!" << std::endl;
89int main(
int argc,
char *argv[]) {
93 number = atoi(argv[1]);
95 std::cout <<
"Enter the value of n(n starts from 0 ): ";
101 std::clock_t start_time = std::clock();
102 for (i = 2; i <= number; i++)
104 std::clock_t end_time = std::clock();
106 static_cast<double>(end_time - start_time) / CLOCKS_PER_SEC;
108 std::cout << number <<
"! = " << result << std::endl
109 <<
"Number of digits: " << result.num_digits() << std::endl
110 <<
"Time taken: " << std::scientific << time_taken <<
" s"