Problem 1: Adding Fibonacci
Problem 1: Adding Fibonacci
Find the sum of all odd Fibonacci numbers up to (and including) a given limit (up to 2 billion). '1' is counted twice.
Inputs: The limit to go up to, supplied as an integer.
Outputs: The sum of the odd Fibonacci numbers below that limit.
Examples:
Inputs: The limit to go up to, supplied as an integer.
Outputs: The sum of the odd Fibonacci numbers below that limit.
Examples:
- Code:
Limit: 5
Fibonacci numbers up to 5: 1, 1, 2, 3, 5
Sum of odd: 1 + 1 + 3 + 5 = 10
- Code:
Limit: 15
Fibonacci numbers up to 15: 1, 1, 2, 3, 5, 8, 13
Sum of odd: 1 + 1 + 3 + 5 + 13 = 23
- Code:
Limit: 4000000
Sum of odd: 4613732
- None. This should be pretty easy.
Elusive- Newbie
- Posts : 10
Join date : 2011-06-04
Permissions in this forum:
You cannot reply to topics in this forum
|
|