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

Function solution

project_euler/problem_206/sol1.py:58–70  ·  view source on GitHub ↗

Returns the first integer whose square is of the form 1_2_3_4_5_6_7_8_9_0

()

Source from the content-addressed store, hash-verified

56
57
58def solution() -> int:
59 """
60 Returns the first integer whose square is of the form 1_2_3_4_5_6_7_8_9_0
61 """
62 num = 138902663
63
64 while not is_square_form(num * num):
65 if num % 10 == 3:
66 num -= 6 # (3 - 6) % 10 = 7
67 else:
68 num -= 4 # (7 - 4) % 10 = 3
69
70 return num * 10
71
72
73if __name__ == "__main__":

Callers 1

sol1.pyFile · 0.70

Calls 1

is_square_formFunction · 0.85

Tested by

no test coverage detected