Question: This is R language 2.1. Define and write a function which takes one number as input and detects whether the number is even. Return TRUE
This is "R" language
2.1. Define and write a function which takes one number as input and detects whether the number is even. Return TRUE if it is even, and FALSE otherwise. You need to first not, return NA detect if the input is an integer if Note 1: TRUE and FALSE are logical values, not strings! Note 2: No need to get user input from the console. Test your function using your_function_name (1), your_function_name (2), and your function name (1.5) Hint: What is the definition of even numbers? In R, you can get the remainder after division using the %% operator (a.k.a. the modulus operator). Example: 5 %% 3 # get the remainder after dividing 5 by 3 2.2. Write a for loop to get the sum of all the even numbers from -50 to 50. You have to use the function you wrote from the above task
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
