June 2017
Beginner
352 pages
8h 39m
English
Remember that when we used factorial() alone it returned an integer. But our more complex expression above for calculating combinations is producing a floating point number. This is because we've used /, Python's floating-point division operator. Since we know our operation will only ever return integral results, we can improve our expression by using //, Python’s integer division operator:
>>> from math import factorial as fac>>> fac(n) // (fac(k) * fac(n - k))10
What's notable is that many other programming languages would fail on the above expression for even moderate values of n. In most programming languages, regular garden variety signed integers can only store values less than {ParseError: KaTeX parse error: ...
Read now
Unlock full access