Using Rstudio:
Write a function prime(n), if the input natural number n is
prime then the function
outputs TRUE; else outputs FALSE. (Hint: please try the following
two examples to find the
way to distinguish prime numbers from non-prime numbers: 5 %% (2 :
4), 4 %% (2 : 3))
(2) In your main script, determine whether each integer in 1 :
10000 is prime or not, save the
result in a Boolean vector. How many prime numbers did you find
less than or equal to
10000?
(3) Let π(π) be the number of primes less than or equal to π. It
has been shown that π(π)βπ
πππ(π). Use your results from (2) to verify this assertion. That
is, draw a figure to show the
curve of π(π) based on your calculation in (2) for π = 1, 2, ...,
10000, and compare it with the
curve of π
πππ(π). You may use different colors for the two curves.
Using Rstudio: Write a function prime(n), if the input natural number n is prime then the function outputs TRUE; else ou
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Using Rstudio: Write a function prime(n), if the input natural number n is prime then the function outputs TRUE; else ou
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!