Question: Please i need this in MATLAB langage y and please defined the variables you used un comments (%). P#7. Trial Division for Primes. The objective
P#7. Trial Division for Primes. The objective of the current program is to implement the Trial Division algorithm in the sorted array with N elements, whichis tharesut-ofthe previeus-problemsin( which have no other divisors except 1 and itself. When a number has more than two factors it is called a composite number (assume one is composite). The mod function is allowed. For instance, if the inputted array is x st. Primes are positive integers 12 LM The numbers are descending order. Output is composed by two tables, (A) one for the prime numbers and the specified position in the prime array, (8) another table with the composite numbers and their position in the composite array as (tables could be one after the other): position prime position composite 4 2 7 9 10 12 5 13 "In the trial division algorithm to check if N is prime, divisors from (2,N-1] are tested, if any of them divides N exactly, then N is not prime, otherwise is prime. Alternatively, test from (1,N) and count how many divides N; counter must not exceeds 2. "Hint: Flip over the array before starting Trial Division. To flip over an array you car use a simple statement: x(1end)-x(end:-1:1)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
