MCPcopy Create free account
hub / github.com/subbarayudu-j/TheAlgorithms-Python / fib

Function fib

project_euler/problem_02/sol2.py:1–11  ·  view source on GitHub ↗

Returns a list of all the even terms in the Fibonacci sequence that are less than n.

(n)

Source from the content-addressed store, hash-verified

1def fib(n):
2 """
3 Returns a list of all the even terms in the Fibonacci sequence that are less than n.
4 """
5 ls = []
6 a, b = 0, 1
7 while b < n:
8 if b % 2 == 0:
9 ls.append(b)
10 a, b = b, a+b
11 return ls
12
13if __name__ == '__main__':
14 n = int(input("Enter max number: ").strip())

Callers 1

sol2.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected