MCPcopy Index your code
hub / github.com/python/cpython / partial_product

Function partial_product

Lib/test/test_math_integer.py:43–55  ·  view source on GitHub ↗

Product of integers in range(start, stop, 2), computed recursively. start and stop should both be odd, with start <= stop.

(start, stop)

Source from the content-addressed store, hash-verified

41 return 1 + count_set_bits(n & n - 1) if n else 0
42
43def partial_product(start, stop):
44 """Product of integers in range(start, stop, 2), computed recursively.
45 start and stop should both be odd, with start <= stop.
46
47 """
48 numfactors = (stop - start) >> 1
49 if not numfactors:
50 return 1
51 elif numfactors == 1:
52 return start
53 else:
54 mid = (start + numfactors) | 1
55 return partial_product(start, mid) * partial_product(mid, stop)
56
57def py_factorial(n):
58 """Factorial of nonnegative integer n, via "Binary Split Factorial Formula"

Callers 1

py_factorialFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…