CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 10:36:27 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=e8150d3078c1ddac17e19e40c5f6af234ba85cf3ba4c7db88117b1a604e98dfda%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22K-Ur3xFCf8l5kyFjFrvRmxALyq6fLGGU%22%3B%7D; HttpOnly; Path=/
cf-ray: 98cdb76e79f0c179-BLR
Project Euler, Problem #2, Python - Pastebin.com
SHARE
TWEET

Project Euler, Problem #2, Python
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python3
- # Каждый следующий элемент ряда Фибоначчи получается при сложении двух
- # предыдущих. Начиная с 1 и 2, первые 10 элементов будут: 1, 2, 3, 5,
- # 8, 13, 21, 34, 55, 89, ... Найдите сумму всех четных элементов ряда
- # Фибоначчи, которые не превышают четыре миллиона.
- # Решение №1
- fib_list = [0,1]
- while fib_list[-1] < 4000000:
- fib_list.append(fib_list[-1] + fib_list[-2])
- print(sum(filter((lambda x: x % 2 == 0), fib_list[0:-1])))
- # 4613732
- # Решение №2
- fib_list = [0,1]
- while fib_list[-1] < 4000000:
- fib_list.append(fib_list[-1] + fib_list[-2])
- even_fib_list = [x for x in fib_list[0:-1] if x % 2 == 0]
- s = 0
- for i in even_fib_list:
- s += i
- print(s)
- # 4613732
- # Решение №3
- fib_list = [0,1]
- while fib_list[-1] < 4000000:
- fib_list.append(fib_list[-1] + fib_list[-2])
- s = 0
- for i in fib_list:
- if i % 2 == 0:
- s += i
- print(s)
- # 4613732
Add Comment
Please, Sign In to add comment
-
⭐✅ Jack's Profit Method ✅ NEVER SEEN BEF...
JavaScript | 6 sec ago | 0.24 KB
-
⭐✅ Online Marketplace Exploit ✅ NEVER SEEN BE...
JavaScript | 16 sec ago | 0.24 KB
-
⭐✅ Trading Profit Method ✅ NEVER SEEN BEFORE...
JavaScript | 24 sec ago | 0.24 KB
-
⭐ Instant BTC Profit Method ✅ NEVER SEEN BEFO...
JavaScript | 33 sec ago | 0.24 KB
-
Free Crypto Method (NEVER SEEN BEFORE)⭐⭐ 5
JavaScript | 38 sec ago | 0.24 KB
-
⭐✅ MAKE $2000 INSTANTLY ✅ NEVER SEEN BEFORE ⭐...
JavaScript | 43 sec ago | 0.24 KB
-
⭐✅ MAKE $2500 IN 15 MIN⭐⭐⭐ 4
JavaScript | 45 sec ago | 0.24 KB
-
⭐ Free Crypto Method ✅ NEVER SEEN BEFORE ⭐⭐⭐
JavaScript | 52 sec ago | 0.24 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand