MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / non_bouncy_exact

Function non_bouncy_exact

project_euler/problem_113/sol1.py:37–47  ·  view source on GitHub ↗

Calculate the number of non-bouncy numbers with at most n digits. >>> non_bouncy_exact(1) 9 >>> non_bouncy_exact(6) 7998 >>> non_bouncy_exact(10) 136126

(n: int)

Source from the content-addressed store, hash-verified

35
36
37def non_bouncy_exact(n: int) -> int:
38 """
39 Calculate the number of non-bouncy numbers with at most n digits.
40 >>> non_bouncy_exact(1)
41 9
42 >>> non_bouncy_exact(6)
43 7998
44 >>> non_bouncy_exact(10)
45 136126
46 """
47 return choose(8 + n, n) + choose(9 + n, n) - 10
48
49
50def non_bouncy_upto(n: int) -> int:

Callers 1

non_bouncy_uptoFunction · 0.85

Calls 1

chooseFunction · 0.85

Tested by

no test coverage detected