Question: Can you please provide a C++ code for this program? thank you The following problem is taken from Project Euler. Each new term in the
Can you please provide a C++ code for this program? thank you
The following problem is taken from Project Euler.
Each new term in the Fibonacci sequence is generated by adding the previous two terms.
By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
Tips:
1) To test and make sure your program works, why not start with a lower number. If you were to add up all even numbers whose value doesnt exceed 100, youd get 44. If you add all even numbers whose value doesnt exceed 200, youd get 188.
Bonus Objectives: Instead of a maximum value of four million, how about 3 billion?
Tips:
1) The values an int can store is typically between -32,767 and 32,767.
2) The values a long int can store is typically between -2,147,483,647 and 2,147,483,647.
3) Look up unsigned int, By eliminating negative values we can almost double our range. Use this to solve 3 billion (thats 3 followed by 9 zeros).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
