On Tue, Nov 24, 2009 at 7:19 AM, Lie Ryan <lie.1...@gmail.com> wrote: > Shashwat Anand wrote: >> >> How can it be done ? > >>>> import decimal, math >>>> D = decimal.Decimal >>>> decimal.getcontext().prec = 100 >>>> sum(D(1) / D(math.factorial(i)) for i in range(1000)) > Decimal('2.718281828459045235360287471352662497757247093699959574966967627724076 > 630353547594571382178525166428')
And with the correct arithmetic, as above, there is no need to compute so many terms. You just have to get to a value of i for which i! > 10^100. i=80 works: In [8]: sum(D(1) / D(math.factorial(i)) for i in range(80)) Decimal('2.718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166428') Kent _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor