Question: Use MATLAB please!!! A prime number N is an integer that is only divisible by 1 and itself (N). Create a function called primey() that

Use MATLAB please!!!

Use MATLAB please!!! A prime number N is an integer that is

A prime number N is an integer that is only divisible by 1 and itself (N). Create a function called primey() that takes as input an integer N and returns as output two items: The answer to the question, "Is N prime?" If N is a prime number, the function primey() returns 'Yes' to the main program and stores it in a variable called answer. If N is not a prime, the function primey() returns 'No' to the main program and stores it in answer. The prime factors of N which are stored in the array primefactors in the main program. For example, if N is 12, the numbers 2, 2, and 3 will be stored in primefactors. If N is 39, the numbers 3 and 13 will be stored in primefactors. If N is a prime number, the numbers 1 and N will be stored in primefactors. You may NOT use the built-in functions factor() or isprime(). N = 15485863; [answer, primefactors] = primey (N); fprintf ('Is %i a prime? %s ', N, answer) fprintf ('The primefactors of %i are: ', N) fprintf ('%i ', primefactors) N = 12345678; [answer, primefactors] = primey (N); fprintf ('IS %i a prime? %s ', N, answer) fprintf ('The primefractors of %i are: ', N) fprintf ('%i ', primefactors)

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!