Learn math and English by programming (Part 2)

problem

https://projecteuler.net/problem=2

English words to use

https://progeigo.org/learning/essential-words-600-plus/ Words starting with B

program


#!/usr/bin/python3
# -*- coding: utf-8 -*-

#This program has no bugs and bitbyte calculations (it seems so)
# This program doesn't have bug and bit byte calc.
#I haven't tried it in a browser
# I dindn't try this on browser.

#Number of bases
based_numgber = 1
#Number of branches (Fibonacci branches at the second number, maybe)
branch_number = 2
#Number of blanks (in the middle)
blank_number = 0
#Back up the total
backup_numgber = branch_number

#Number to block the calculation
block_numger = 4000000

#Boolean flag (I don't understand the meaning)
boolean_flag = True

while boolean_flag :
    blank_number = based_numgber + branch_number
    based_numgber = branch_number
    branch_number = blank_number

    if blank_number >= block_numger :
        break

    if blank_number % 2 == 0 :
        backup_numgber += blank_number

print(backup_numgber)

Execution result


# python3 test.py
4613732

Conclusion

I'll get angry if such a variable name is written

Recommended Posts

Learn math and English by programming (Part 2)
Learn math and English through programming (Part 1)
Making sound by programming Part 2
Learn Python and AI related English words. .. ..
Learn about programming
[Python] Learn about asynchronous programming and event loops
[Programming learning] Logic comparison by language part.1 ("Hello World")
GUI programming with kivy ~ Part 3 Video and seek bar ~
Linear programming by Karmarkar's algorithm
Making sound by programming Part 2
Learn "English grammar" instead of Python and AI related English words. .. ..
Machine learning to learn with Nogizaka46 and Keyakizaka46 Part 1 Introduction
Memoization recursion and dynamic programming known by Python Fibonacci sequence