-3

I am not sure whether this is related to math.factorial function or it is related to some typecasting or whatever. This is what I know:

>>> factorial(52)/ (factorial(52-48) - factorial(48))
-6497401L

So, with that code I am trying to calculate the number of possible combinations of a set of 52 different elements taken in groups of 48. And the result I am getting is a negative number, that makes no sense at all.

Any ideas why is this happening?

8
  • 2
    factorial(52-48) means factorial(4). If you subtract factorial(48) from this you will get a negative number. Commented Mar 4, 2016 at 11:55
  • 2
    You are getting a negative number because factorial(52-48) is the same as factorial(4) which is negative when you subtract factorial(48) from it. With a positive numerator and a negative denominator, you're bound to get a negative result. Commented Mar 4, 2016 at 11:56
  • Ah, I see. I committed a typo and put a - where I should have put an *. Commented Mar 4, 2016 at 11:57
  • Can I remove this question somehow? Commented Mar 4, 2016 at 11:58
  • 1
    @Fran You can delete your own question Commented Mar 4, 2016 at 12:02

1 Answer 1

3

Your math is wrong. It should be N!/(S! * (S - N)!) - you are subtracting instead of multiplying in the denominator:

>>> factorial(52) / (factorial(52-48) * factorial(48))
270725L
Sign up to request clarification or add additional context in comments.

1 Comment

The OP would like to delete this Q because it's just a typo.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.