Using Rstudio: Write a function prime(n), if the input natural number n is prime then the function outputs TRUE; else ou

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
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

Post by answerhappygod »

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.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply