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

Function solution

project_euler/problem_045/sol1.py:44–55  ·  view source on GitHub ↗

Returns the next number which is triangular, pentagonal and hexagonal. >>> solution(144) 1533776805

(start: int = 144)

Source from the content-addressed store, hash-verified

42
43
44def solution(start: int = 144) -> int:
45 """
46 Returns the next number which is triangular, pentagonal and hexagonal.
47 >>> solution(144)
48 1533776805
49 """
50 n = start
51 num = hexagonal_num(n)
52 while not is_pentagonal(num):
53 n += 1
54 num = hexagonal_num(n)
55 return num
56
57
58if __name__ == "__main__":

Callers 1

sol1.pyFile · 0.70

Calls 2

hexagonal_numFunction · 0.85
is_pentagonalFunction · 0.70

Tested by

no test coverage detected