Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7007423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:36:19+00:00 2026-05-27T21:36:19+00:00

I was solving a Project Euler problem that goes as follows: By considering the

  • 0

I was solving a Project Euler problem that goes as follows:

By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.”

So I used this script to print the Fibonacci sequence up to four million:

a = 0
b = 1
while b < 4000000:
    print b
    a, b = b, a+b

Obviously, I could run this and just manually add the even values, but I would feel like I’m cheating.

Technically, I guess I’m asking two questions:

  1. How could I pick out the evens?
  2. How could I add those evens without actually assigning them to a variable?

Oh, and I’m sure its extremely evident, but I’m very new to…well, programming in general and I can get lost in experts’ verbosity easily. Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:36:19+00:00Added an answer on May 27, 2026 at 9:36 pm

    How could I pick out the evens?

    Even numbers are the ones that leave a remainder of zero when you divide them by 2 (in integers). In Python, we get ‘the remainder after dividing as an integer’ with the % operator.

    However, there’s another neat trick you can do here. The even Fibonacci numbers are every third number in the sequence, and if you can rigorously prove why, then you’ll be close to getting the formula needed to just generate the sequence of even Fibonacci numbers directly.

    How could I add those evens without actually assigning them to a variable?

    What’s wrong with assigning them to a variable? Just set up another one for the running count.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am solving problem 9 on the Project Euler . In my solution I
I'm playing with Haskell and Project Euler's 23rd problem. After solving it with lists
Possible Duplicate: Need help solving Project Euler problem 200 Similar to this question Project
Project Euler problem 14: The following iterative sequence is defined for the set of
I'm working on solving the Project Euler problem 25: What is the first term
I am learning ruby and practicing it by solving problems from Project Euler .
While solving some Project Euler Problems to learn Haskell (so currently I'm a completly
I am solving some problems of Project Euler in Haskell. I wrote a program
I'm currently working on a project Euler problem (www.projecteuler.net) for fun but have hit
I've been wrestling with Project Euler Problem #16 in C# 2.0. The crux of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.