yes but i'm a little ot because it is C++...
So, let's try something /on-topic/, then, shall we?
/*
** This program was inspired by the article "The Impossible Dream:
** Computing e to 116,000 places with a Personal Computer" by
** Stephen Wozniak, published in Byte Magazine Vol 6, Issue 6
** (June 1981, pp392).
**
** Essentially, the following program implements a partial expansion
** of the equation: e = 1 + (1/1!) + (1/2!) + (1/3!) + ... + (1/n!)
** by inverting the equation, such that it reads...
** e = (((((...(((((1/n) + 1) / (n-1)) + 1) ... / 3) + 1) / 2) + 1) /
1) + 1
**
** I originally wrote this program in Z80 Assembler code, to run under
** CP/M (Dec 1986), and subsequently have recoded the program in
** 370 Assembler to run under MVS and VSE, and C to run under MSDOS
** and Linux
**
** Lew Pitcher, 1999
*/
#include <stdio.h>
#define I 1 /* number of bytes in integer portion */
#define X 2078 /* number of bytes in fraction portion */
#define N 1776 /* number of divide iterations */
#define P 5000 /* number of multiply iterations */
char e[I+X]; /* holds fixed point binary value of e */
int main(void)
{
void divide(char *, unsigned, unsigned),
multiply(char *, unsigned, unsigned);
unsigned n, /* divisor for calculation loop */
p; /* precision for print loop */
e[0] = 1; /* start the series at 1.anything */
for (n = N; n > 0; --n)
{
divide(e,n,I+X);
e[0] += 1;
}
fputs(" e == ",stdout); fputc(e[0]+'0',stdout); fputc('.',stdout);
for (p = 0; p < P; ++p)
{
e[0] = 0;
multiply(e,10,I+X);
fputc(e[0]+'0',stdout);
if (p%5 == 4)
if (p%50 == 49)
fputs("\n\t",stdout);
else
fputc(' ',stdout);
}
fputc('\n',stdout);
return 0;
}
void divide(char *dvd, unsigned dvr, unsigned prc)
{
char *Wk_q;
unsigned bit, rmdr;
rmdr = 0;
for (Wk_q = dvd; Wk_q < dvd+prc; ++Wk_q)
{
for(bit = 0; bit < 8; ++bit)
{
rmdr *= 2;
if (*Wk_q & 0200) rmdr += 1;
*Wk_q <<= 1;
if (rmdr >= dvr)
{
*Wk_q += 1;
rmdr -= dvr;
}
}
}
}
void multiply(char *mcd, unsigned mpy, unsigned prc)
{
char *Wk_r;
unsigned bit, ovflo;
ovflo = 0;
for (Wk_r = mcd+prc-1; Wk_r >= mcd; --Wk_r)
{
for (bit = 8; bit > 0; --bit)
{
if (*Wk_r & 1) ovflo += mpy;
*Wk_r >>= 1; *Wk_r &= 0177;
if (ovflo & 1) *Wk_r = *Wk_r | 0200;
ovflo /= 2;
}
}
}
=========================== output ============================
e == 2.71828 18284 59045 23536 02874 71352 66249 77572 47093 69995
95749 66967 62772 40766 30353 54759 45713 82178 52516 64274
27466 39193 20030 59921 81741 35966 29043 57290 03342 95260
59563 07381 32328 62794 34907 63233 82988 07531 95251 01901
15738 34187 93070 21540 89149 93488 41675 09244 76146 06680
82264 80016 84774 11853 74234 54424 37107 53907 77449 92069
55170 27618 38606 26133 13845 83000 75204 49338 26560 29760
67371 13200 70932 87091 27443 74704 72306 96977 20931 01416
92836 81902 55151 08657 46377 21112 52389 78442 50569 53696
77078 54499 69967 94686 44549 05987 93163 68892 30098 79312
77361 78215 42499 92295 76351 48220 82698 95193 66803 31825
28869 39849 64651 05820 93923 98294 88793 32036 25094 43117
30123 81970 68416 14039 70198 37679 32068 32823 76464 80429
53118 02328 78250 98194 55815 30175 67173 61332 06981 12509
96181 88159 30416 90351 59888 85193 45807 27386 67385 89422
87922 84998 92086 80582 57492 79610 48419 84443 63463 24496
84875 60233 62482 70419 78623 20900 21609 90235 30436 99418
49146 31409 34317 38143 64054 62531 52096 18369 08887 07016
76839 64243 78140 59271 45635 49061 30310 72085 10383 75051
01157 47704 17189 86106 87396 96552 12671 54688 95703 50354
02123 40784 98193 34321 06817 01210 05627 88023 51930 33224
74501 58539 04730 41995 77770 93503 66041 69973 29725 08868
76966 40355 57071 62268 44716 25607 98826 51787 13419 51246
65201 03059 21236 67719 43252 78675 39855 89448 96970 96409
75459 18569 56380 23637 01621 12047 74272 28364 89613 42251
64450 78182 44235 29486 36372 14174 02388 93441 24796 35743
70263 75529 44483 37998 01612 54922 78509 25778 25620 92622
64832 62779 33386 56648 16277 25164 01910 59004 91644 99828
93150 56604 72580 27786 31864 15519 56532 44258 69829 46959
30801 91529 87211 72556 34754 63964 47910 14590 40905 86298
49679 12874 06870 50489 58586 71747 98546 67757 57320 56812
88459 20541 33405 39220 00113 78630 09455 60688 16674 00169
84205 58040 33637 95376 45203 04024 32256 61352 78369 51177
88386 38744 39662 53224 98506 54995 88623 42818 99707 73327
61717 83928 03494 65014 34558 89707 19425 86398 77275 47109
62953 74152 11151 36835 06275 26023 26484 72870 39207 64310
05958 41166 12054 52970 30236 47254 92966 69381 15137 32275
36450 98889 03136 02057 24817 65851 18063 03644 28123 14965
50704 75102 54465 01172 72115 55194 86685 08003 68532 28183
15219 60037 35625 27944 95158 28418 82947 87610 85263 98139
55990 06737 64829 22443 75287 18462 45780 36192 98197 13991
47564 48826 26039 03381 44182 32625 15097 48279 87779 96437
30899 70388 86778 22713 83605 77297 88241 25611 90717 66394
65070 63304 52795 46618 55096 66618 56647 09711 34447 40160
70462 62156 80717 48187 78443 71436 98821 85596 70959 10259
68620 02353 71858 87485 69652 20005 03117 34392 07321 13908
03293 63447 97273 55955 27734 90717 83793 42163 70120 50054
51326 38354 40001 86323 99149 07054 79778 05669 78533 58048
96690 62951 19432 47309 95876 55236 81285 90413 83241 16072
26029 98330 53537 08761 38939 63917 79574 54016 13722 36187
89365 26053 81558 41587 18692 55386 06164 77983 40254 35128
43961 29460 35291 33259 42794 90433 72990 85731 58029 09586
31382 68329 14771 16396 33709 24003 16894 58636 06064 58459
25126 99465 57248 39186 56420 97526 85082 30754 42545 99376
91704 19777 80085 36273 09417 10163 43490 76964 23722 29435
23661 25572 50881 47792 23151 97477 80605 69672 53801 71807
76360 34624 59278 77846 58506 56050 78084 42115 29697 52189
08740 19660 90665 18035 16501 79250 46195 01366 58543 66327
12549 63990 85491 44200 01457 47608 19302 21206 60243 30096
41270 48943 90397 17719 51806 99086 99860 66365 83232 27870
93765 02260 14929 10115 17177 63594 46020 23249 30028 04018
67723 91028 80978 66605 65118 32600 43688 50881 71572 38669
84224 22010 24950 55188 16948 03221 00251 54264 94639 81287
36776 58927 68816 35983 12477 88652 01411 74110 91360 11649
95076 62907 79436 46005 85194 19985 60162 64790 76153 21038
72755 71269 92518 27568 79893 02761 76114 61625 49356 49590
37980 45838 18232 33686 12016 24373 65698 46703 78585 33052
75833 33793 99075 21660 69238 05336 98879 56513 72855 93883
49989 47074 16181 55012 53970 64648 17194 67083 48197 21448
88987 90676 50379 59036 69672 49499 25452 79033 72963 61626
58976 03949 85767 41397 35944 10237 44329 70935 54779 82629
61459 14429 36451 42861 71585 87339 74679 18975 71211 95618
73857 83644 75844 84235 55581 05002 56114 92391 51889 30994
63428 41393 60803 83091 66281 88115 03715 28496 70597 41625
62823 60921 68075 15017 77253 87402 56425 34708 79089 13729
17228 28611 51591 56837 25241 63077 22544 06337 87593 10598
26760 94420 32619 24285 31701 87817 72960 23541 30606 72136
04600 03896 61093 64709 51414 17185 77701 41806 06443 63681
54644 40053 31608 77831 43174 44081 19494 22975 59931 40118
88683 31483 28027 06553 83300 46932 90115 74414 75631 39997
22170 38046 17092 89457 90962 71662 26074 07187 49975 35921
27560 84414 73782 33032 70330 16823 71936 48002 17328 57349
35947 56433 41299 43024 85023 57322 14597 84328 26414 21684
87872 16733 67010 61509 42434 56984 40187 33128 10107 94512
72237 37886 12605 81656 68053 71439 61278 88732 52737 38903
92890 50686 53241 38062 79602 59303 87727 69778 37928 68409
32536 58807 33988 45721 87460 21005 31148 33513 23850 04782
71693 76218 00490 47955 97959 29059 16554 70505 77751 43081
75112 69898 51884 08718 56402 60353 05583 73783 24229 24185
62564 42550 22672 15598 02740 12617 97192 80471 39600 68916
38286 65277 00975 27670 69777 03643 92602 24372 84184 08832
51848 77047 26384 40379 53016 69054 65937 46161 93238 40363
89313 13643 27137 68884 10268 11219 89127 52230 56256 75625
47017 25086 34976 53672 88605 96675 27408 68627 40791 28565
76996 31378 97530 34660 61666 98042 18267 72456 05306 60773
89962 42183 40859 88207 18646 82623 21508 02882 86359 74683
96543 58856 68550 37731 31296 58797 58105 01214 91620 76567
69950 65971 53447 63470 32085 32156 03674 82860 83786 56803
07306 26576 33469 77429 56346 43716 70939 71930 60876 96349
53288 46833 61303 88294 31040 80029 68738 69117 06666 61468