Skip to content
Thomas Lehmann edited this page Jun 6, 2015 · 1 revision

As an example for using the big integer I provided the factorial tool. Using --help you can see the available options. By default the tool prints all factorial up to defined number otherwise the requested (final) factorial number only.

Using the help

thomas@thomas-Inspiron-1110 /work/projects/concept-cpp/build $ examples/factorial --help
Allowed options for tool 'factorial':
  --help                print this help
  --n arg (=100)        Calculating factorial: n! (default: 100)
  --all arg (=1)        showing each factorials until 'n!' (default: true)

Displaying all factorial up to given number

thomas@thomas-Inspiron-1110 /work/projects/concept-cpp/build $ examples/factorial --n 30 --all=true
30!

2
6
24
120
720
5040
40320
362880
3628800
39916800
479001600
6227020800
87178291200
1307674368000
20922789888000
355687428096000
6402373705728000
121645100408832000
2432902008176640000
51090942171709440000
1124000727777607680000
25852016738884976640000
620448401733239439360000
15511210043330985984000000
403291461126605635584000000
10888869450418352160768000000
304888344611713860501504000000
8841761993739701954543616000000
265252859812191058636308480000000

 ... 33 digits.
 ... Calculation only took 0.321549ms.

Displaying the final factorial number only

thomas@thomas-Inspiron-1110 /work/projects/concept-cpp/build $ examples/factorial --n 1000 --all=false
1000!

40238726007709377354370243392300398571937486421071463254379991042993851239862902059204420848696940480047
99886101971960586316668729948085589013238296699445909974245040870737599188236277271887325197795059509952
76120874975462497043601418278094646496291056393887437886487337119181045825783647849977012476632889835955
73543251318532395846307555740911426241747434934755342864657661166779739666882029120737914385371958824980
81268678383745597317461360853795345242215865932019280908782973084313928444032812315586110369768013573042
16168747609675871348312025478589320767169132448426236131412508780208000261683151027341827977704784635868
17016436502415369139828126481021309276124489635992870511496497541990934222156683257208082133318611681155
36158365469840467089756029009505376164758477284218896796462449451607653534081989013854424879849599533191
01723355556602139450399736280750137837615307127761926849034352625200015888535147331611702103968175921510
90778801939317811419454525722386554146106289218796022383897147608850627686296714667469756291123408243920
81601537808898939645182632436716167621791689097799119037540312746222899880051954444142820121873617459926
42956581746628302955570299024324153181617210465832036786906117260158783520751516284225540265170483304226
14397428693306169089796848259012545832716822645806652676995865268227280707578139185817888965220816434834
48259932660433676601769996128318607883861502794659551311565520360939881806121385586003014356945272242063
44631797460594682573103790084024432438465657245014402821885252470935190620929023136493273497565513958720
55965422874977401141334696271542284586237738753823048386568897646192738381490014076731044664025989949022
22217659043399018860185665264850617997023561938970178600408118897299183110211712298459016419210688843871
21855646124960798722908519296819372388642614839657382291123125024186649353143970137428531926649875337218
94069428143411852015801412334482801505139969429015348307764456909907315243327828826986460278986432113908
35062170950025973898635542771967428222487575867657523442202075736305694988250879689281627538488633969099
59826280956121450994871701244516461260379029309120889086942028510640182154399457156805941872748998094254
74217358240106367740459574178516082923013535808184009699637252423056085590370062427124341690900415369010
59339838357779394109700277534720000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000

 ... 2568 digits.
 ... Calculation only took 470.012ms.