Intermediate Algorithm Scripting - Sum All Odd Fibonacci Numbers

Hello everyone, i have a question. I don’t get this challenge, what am i suppose to do to the number and the fibonacci numbers that are less than the number?

To make it clear, these are lists of things i understood and this i don’t understood yet:

What i am aware of:
1- what are fibonacci numbers
2- we need to see if the fibonacci numbers are less or equal to the number
3- owe need to see if the fibonacci numbers are also odd
4- we need to sum all odd fibonacci numbers that are less or equal to the number

What i don’t get:

1- how come the return result.
For example. How if we pass 4 to the arguments we will return 5, why process we need to follow? What do we need to do with the fibonacci odd numbers and the number?

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Safari/605.1.15

Challenge Information:

Intermediate Algorithm Scripting - Sum All Odd Fibonacci Numbers

Taking for example first seven numbers from sequence, and num === 4:

0 1 1 2 3 5 8
  | | | | | ^ higher than 4
  | | | | ^ higher than 4
  | | | ^ lower than 4, odd
  | | ^ lower than 4, even
  | ^ lower than 4, odd
  ^ lower than 4, odd

After removing the not needed numbers, what is left:

  1 1   3

Sum of these numbers is 5, what is the expected answer for sumFibs(4)

2 Likes

Hi bushra,

sanity has provided an excellent example above. I would just add that you need to somehow iterate over the num argument to get all the odd numbers. At this point, I’m sure you’re familiar with the syntax to perform iteration.

Once you get that, ask yourself what you can do to fulfill the task. The key is:

Return the sum of all odd Fibonacci numbers that are less than or equal to num.

Take your time to read through the instructions. You can do this

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.