Question: Write a MATLAB program for the above situation. thank you! Prime numbers are commonly used in computing as part of encryption systems, amongst other applications.

 Write a MATLAB program for the above situation. thank you! Prime

Write a MATLAB program for the above situation. thank you!

Prime numbers are commonly used in computing as part of encryption systems, amongst other applications. As such, the identification of these numbers, which are divisible only by themselves and 1, is fundamental to many programs. The simplest means used to identify primes numbers is the process of division by all previously identified prime numbers. Any candidate number which is evenly divisible by an existing prime (i.e. with a remainder of 0) is by definition not a prime number Using the starting candidate prime numbers 2 and 3 as an array [2 3], write a program to determine the first n prime numbers (including the two already defined) and store them in the same array. The following details must be included: .Inputs: - Primes- a row vector of the prime numbers 2 and 3 and to which all subsequent identified primes must be added -NumberofPrimes - a scalar value stating the number of primes that must be calculated. . Outputs: - Primes a row vector of the first n prime numbers, where n is defined by the variable NumberofPrimes. . Only the variable Primes may remain in the workspace once the program has finished execution The program may not display to the console The program may only use basic algebraic operations (addition, subtraction, multiplication, and division) . . . The built-in function modulo may not be used . The floor function may be used. As the required program is a script, it may be assumed that the variables Primes and NumberofPrimes will exist in the workspace at execution and that the output variables, and only those specified, must remain in the workspace at the end of execution. Students are encouraged to draw a flow chart of the required program to aid in program design

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!