Question: Write using R code. Refer to the image. Problem 2 . Assume you have a function check.prime that can be used to check whether a

Write using R code. Refer to the image. Problem 2. Assume you have a function check.prime that can be used to check whether
a given natural number is a prime. [Modify your own code or one of mine posted in the
solution of homework 3].
a. Based on the function check.prime, create a new function that can count the number
of primes smaller than or equal to the given natural number. Name this new function
count.prime.
b. Consider a sequence x=100**seq(1:500). Let y be a vector with the same length as x
and the i th element of y(i.c.,yi) is the count of prime numbers up to the i th clement
of x(i.e.,xi). Define z=xlog(x). Display the last 20 values of x,y, and z. For
example, you can use the command tail (cbind (x,y,z).
c. Plot y versus x. On the same figure, add a curve z versus x. Distinguish the two
curves with different line types and colors. Add legend too. In a separate figure, plot
yz versus x. Make comments on the relationship between y and z when x is large.
Search "Prime number theorem" for reference to help make your comments.
 Write using R code. Refer to the image. Problem 2. Assume

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!