NSBCoding
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Problem 1: Adding Fibonacci

Go down

Problem 1: Adding Fibonacci Empty Problem 1: Adding Fibonacci

Post  Elusive Sat Jun 04, 2011 11:56 am

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:
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
Tips:
  1. None. This should be pretty easy.

Elusive
Newbie

Posts : 10
Join date : 2011-06-04

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum