Multiply
Write 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 of3and5is15.
Example 2:
Input:
a = -2, b = -4
Output:8
Explanation: The product of-2and-4is8.
Example 3:
Input:
a = 0, b = 200
Output:0
Explanation: The product of0and200is0.
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`.
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.
MathFactorial
easyWrite a function `factorial` that takes a non-negative integer and returns its factorial. ## Function Signature ```function factorial(num);``` ### Example 1: > **Input:** `num = 5`\ > **Output:** `120`\ > **Explanation:** The factorial of 5 is `5! = 5 * 4 * 3 * 2 * 1 = 120`. ### Example 2: > **Input:** `num = 0`\ > **Output:** `1`\ > **Explanation:** The factorial of 0 is defined as `1`. ### Example 3: > **Input:** `num = 3`\ > **Output:** `6`\ > **Explanation:** The factorial of 3 is `3! = 3 * 2 * 1 = 6`.
Math