Question: Write using R code..... The purpose of this problem is to write a function ( say its name is check.prime ) to check whether or
Write using R code..... The purpose of this problem is to write a function say its name is check.prime to check whether or not a given natural number is a prime. The input of check.prime should be a positive integer and the output should be a list containing a logic variable called result and a character variable called report, which tells if the input is a prime. Specific requirements are implied from the following examples.
a If one feeds anything but a positive integer, assign NA to result and report will be Error The input must be a positive integer
b We know is a prime number. Implementing check.prime will yield a T or TRUE for result and The input IS a prime number. for report.
c Implementing check.prime will yield a F or FALSE for result and The input IS NOT a prime number. for report.
Complete the following tasks and present your output.
i Implement your R function with and one by one and show your results.
ii Implement xfloorrunif; check.primex for three times and display your output.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
