We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8d4d950 commit 16e95a3Copy full SHA for 16e95a3
project_euler/problem_02/sol2.py
@@ -1,12 +1,15 @@
1
def fib(n):
2
- a, b, s = 0, 1, 0
+ """
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:
- if b % 2 == 0 and b < n: s += b
8
+ if b % 2 == 0:
9
+ ls.append(b)
10
a, b = b, a+b
- ls.append(s)
11
+ return ls
12
-T = int(input().strip())
-ls = []
-for _ in range(T):
- fib(int(input().strip()))
-print(ls, sep = '\n')
13
+if __name__ == '__main__':
14
+ n = int(input("Enter max number: ").strip())
15
+ print(sum(fib(n)))
project_euler/Problem 31/sol1.py renamed to project_euler/problem_31/sol1.py
0 commit comments