@Mark,

The str(...).split('.') here doesn't do a good job of extracting the
> integer part when its argument is >= 1e12, since Python produces a
> result in scientific notation.  I think you're going to get strange
> results when k >= 13.
>

Yeah, you were correct. I tested it for k >= 13, and there were issues i.e.
only one character is printed.
Shashwat-Anands-MacBook-Pro:Desktop l0nwlf$ python CALCULAT.py
3
1000000 12 12
826393051664 000000000000
1000000 13 13
8 0000000000000
100 15 4
9 0000

The logic I tried was : for
alpha = n!
log(alpha) = log(n!)
                = log(n) + log(n-1) + .. log(2) + log(1)
                = e [where e = log(n) + .... + log(1)]

frac_e =  {e} (fractional part of e, like {1.23} = .23)
now last k digits of alpha = 10**frac_e * 10**(k - 1)

As I can see, the method is mathematically sound, and there is precision
issues. Time for code modification.

~l0nwlf
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to