MCPcopy Create free account
hub / github.com/Mrinank-Bhowmick/python-beginner-projects / compute

Function compute

projects/ProjectEuler/Problem 2/p2.py:1–9  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1def compute():
2 ans = 0
3 x = 1 # Represents the current Fibonacci number being processed
4 y = 2 # Represents the next Fibonacci number in the sequence
5 while x <= 4000000:
6 if x % 2 == 0:
7 ans += x
8 x, y = y, x + y
9 return str(ans)
10
11
12if __name__ == "__main__":

Callers 1

p2.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected