Calculate Fibonacci Number
Calculate the n-th Fibonacci number.
Function Signature
function fibonacci(n);
Example 1:
Input:
n = 5
Output:5
Explanation: The 5th Fibonacci number is 5 (0, 1, 1, 2, 3, 5).
Example 2:
Input:
n = 10
Output:55
Explanation: The 10th Fibonacci number is 55.
Solve this problem
Start your 7-day free trial to solve this problem in our code editor with instant feedback.
Start 7-Day Free Trial to Solve This ProblemRelated Problems
Two Sum
easyWrite a function `twoSum` that takes two integers `a` and `b` and returns their sum. ## Function Signature ```function twoSum(a, b);``` ### Example 1: > **Input:** `a = 3, b = 5`\ > **Output:** `8`\ > **Explanation:** The sum of `3` and `5` is `8`. ### Example 2: > **Input:** `a = -2, b = -4`\ > **Output:** `-6`\ > **Explanation:** The sum of `-2` and `-4` is `-6`. ### Example 3: > **Input:** `a = 100, b = 200`\ > **Output:** `300`\ > **Explanation:** The sum of `100` and `200` is `300`.
MathMultiply
easyWrite a function `multiply` that takes two integers `a` and `b` and returns their product. ## Function Signature ```function multiply(a, b);``` ### Example 1: > **Input:** `a = 3, b = 5`\ > **Output:** `15`\ > **Explanation:** The product of `3` and `5` is `15`. ### Example 2: > **Input:** `a = -2, b = -4`\ > **Output:** `8`\ > **Explanation:** The product of `-2` and `-4` is `8`. ### Example 3: > **Input:** `a = 0, b = 200`\ > **Output:** `0`\ > **Explanation:** The product of `0` and `200` is `0`.
MathIs Even
easyWrite a function `isEven` that takes an integer and returns true if it is even, false otherwise. ## Function Signature ```function isEven(num);``` ### Example 1: > **Input:** `num = 4`\ > **Output:** `true`\ > **Explanation:** The number 4 is even. ### Example 2: > **Input:** `num = 7`\ > **Output:** `false`\ > **Explanation:** The number 7 is not even. ### Example 3: > **Input:** `num = 0`\ > **Output:** `true`\ > **Explanation:** The number 0 is even.
Math