-
Notifications
You must be signed in to change notification settings - Fork 0
/
2.py
71 lines (58 loc) · 965 Bytes
/
2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
f = [1, 2]
a = 0
s = 0 # summ
for i in f:
c = (f[a] + f[a + 1])
if c < 4000000:
f.append(c)
a += 1
for i in f:
if i % 2 == 0:
s = s + i
print(s)
a = 1
b = 2
s = b
while b < 4*10**6:
a = a + b
b = a + b
s += b
print(s)
s, a, b = 0, 1, 2
while b < 4*10**6:
if b % 2 == 0:
s += b
a, b = b, a + b
print(s)
fib = [1, 2]
sum = 2
while True:
fib.append(fib[-1] + fib[-2])
if fib[-1] > 4000000:
break
if fib[-1] % 2 == 0:
sum += fib[-1]
print(sum)
s = [1, 2]
for i in s:
i += s[-1]
s.extend([i])
a = 0
for i in s:
if i % 2 == 0:
a += i
if i >= 4000000:
break
print(a)
f = [1, 2]
a = 0
s = 0 # summ
for i in f:
c = (f[a] + f[a + 1])
if c < 4000000:
f.append(c)
a += 1
for i in f:
if i % 2 == 0:
s = s + i
print(s)