Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 37 is a prime number. Implementing check.prime(37) will yield a T or TRUE for result and The input 37 IS a prime number. for report.
c. Implementing check.prime(51) will yield a F or FALSE for result and The input 51 IS NOT a prime number. for report.
Complete the following tasks and present your output.
(i). Implement your R function with 5,21,47.5,63,87, and 111 one by one and show your results.
(ii). Implement x=floor(100*runif(1)); check.prime(x) for three times and display your output.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 1 Lncs 13426

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124227, 978-3031124228

More Books

Students also viewed these Databases questions

Question

=+j Improve the effectiveness of global and virtual teams.

Answered: 1 week ago