calculate.py 328 B

123456789101112131415
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. from math import factorial
  4. from gmpy import bincoef
  5. f = open('data.csv', 'w')
  6. f.write('People\tprobability\n')
  7. def prob(people):
  8. return 1.0 - float(factorial(people)*bincoef(365,people))/(365**people)
  9. for people in xrange(60+1):
  10. f.write("%i\t%f\n" % (people, prob(people)))