Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write the code in R. Write a function named prime_factor(x) that will nd the prime factorization of an integer x. The function will output

Please write the code in R.

image text in transcribed
Write a function named prime_factor(x) that will nd the prime factorization of an integer x. The function will output a numeric vector. All of the values in the output vector will be prime. The product of the numeric vector will be the original value x. There should be a check to make sure that the input value is a number greater than or equal to 2 with no decimal values with appropriate error messages. If you're stuck on getting started with this, I suggest doing some prime factorizations yourself. For example, try to nd the prime factors of 171 or 364. Note the steps you go through to nd these prime factors and see if you can create code to do it. (The point of the exercise is to give you practice writing code. Yes, I am aware that solutions to this problem already exist on the Internet. Don't search for them. While the problem is simple, it is complex enough that it is incredibly unlikely for students to create identical code solutions. You are free to talk about your approach and I fully expect many students to take identical approaches, but students writing identical code is an entirely different matter.)

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

Step: 3

blur-text-image

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

How To Prove It A Structured Approach

Authors: Daniel J Velleman

2nd Edition

0511159439, 9780511159435

More Books

Students also viewed these Mathematics questions