mirror of
https://github.com/python/cpython.git
synced 2025-10-15 19:29:46 +00:00
Close #28476: Reuse math.factorial() in test_random
Patch written by Francisco Couzo.
This commit is contained in:
parent
26d0ccd51b
commit
bd1b49a242
1 changed files with 1 additions and 5 deletions
|
@ -5,7 +5,7 @@ import time
|
||||||
import pickle
|
import pickle
|
||||||
import warnings
|
import warnings
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from math import log, exp, pi, fsum, sin
|
from math import log, exp, pi, fsum, sin, factorial
|
||||||
from test import support
|
from test import support
|
||||||
from fractions import Fraction
|
from fractions import Fraction
|
||||||
|
|
||||||
|
@ -117,10 +117,6 @@ class TestBasicOps:
|
||||||
n = 5
|
n = 5
|
||||||
pop = range(n)
|
pop = range(n)
|
||||||
trials = 10000 # large num prevents false negatives without slowing normal case
|
trials = 10000 # large num prevents false negatives without slowing normal case
|
||||||
def factorial(n):
|
|
||||||
if n == 0:
|
|
||||||
return 1
|
|
||||||
return n * factorial(n - 1)
|
|
||||||
for k in range(n):
|
for k in range(n):
|
||||||
expected = factorial(n) // factorial(n-k)
|
expected = factorial(n) // factorial(n-k)
|
||||||
perms = {}
|
perms = {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue