/[gzz]/manuscripts/Sigs/poss.py
ViewVC logotype

Diff of /manuscripts/Sigs/poss.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by tjl, Sun May 18 19:47:11 2003 UTC revision 1.8 by tjl, Sun May 18 21:11:59 2003 UTC
# Line 2  from fractions import fraction Line 2  from fractions import fraction
2  import math  import math
3  from math import log, log10, ceil  from math import log, log10, ceil
4    
5    factorials = {}
6  def fact(x):  def fact(x):
7      return reduce(lambda a, b: a*b, range(1, x+1), 1L)      a = factorials.get(x, None)
8        if a == None:
9            a = reduce(lambda a, b: a*b, range(1, x+1), 1L)
10            factorials[x] = a
11        return a
12    
13  def choose(n, k):  def choose(n, k):
14      return fact(n) / (fact(k)*fact(n-k))      return fact(n) / (fact(k)*fact(n-k))

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26