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

Function non_bouncy_upto

project_euler/problem_113/sol1.py:50–60  ·  view source on GitHub ↗

Calculate the number of non-bouncy numbers with at most n digits. >>> non_bouncy_upto(1) 9 >>> non_bouncy_upto(6) 12951 >>> non_bouncy_upto(10) 277032

(n: int)

Source from the content-addressed store, hash-verified

48
49
50def non_bouncy_upto(n: int) -> int:
51 """
52 Calculate the number of non-bouncy numbers with at most n digits.
53 >>> non_bouncy_upto(1)
54 9
55 >>> non_bouncy_upto(6)
56 12951
57 >>> non_bouncy_upto(10)
58 277032
59 """
60 return sum(non_bouncy_exact(i) for i in range(1, n + 1))
61
62
63def solution(num_digits: int = 100) -> int:

Callers 1

solutionFunction · 0.85

Calls 1

non_bouncy_exactFunction · 0.85

Tested by

no test coverage detected