Question: IN MATLAB PROGRAMMING PLEASE!! Write a function prime_isolated(a, b) that returns as output (argument) ALL prime numbers p in the interval [a, b] (inclusive) for
Write a function prime_isolated(a, b) that returns as output (argument) ALL prime numbers p in the interval [a, b] (inclusive) for which neither p - 2 NOR p + 2 arc prime numbers (which are called isolated primes). The "Sieve of Eratosthenes" (https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes) is the simplest way to find prime numbers, but you can choose a different algorithm. (Do NOT use the built-in MATLAB function isprime other than to check your results.) When given only one input, your function should find all isolated primes in the interval [1, a]. You must VERIFY that the numbers your function found arc isolated primes (e.g. by comparing it to lists of isolated prime numbers or using the built-in MATLAB function isprime). Write a detailed structure plan implementing your algorithm that satisfies the program scope- specification laid out above. Write the function primeisolated based on YOUR structure plan. Use your function to do the following: find all isolated primes below 20 by calling prime_isolated(20) find all isolated primes in the interval [20, 50] by calling prime_isolated(20, 50) find all isolated primes in the interval [50, 100] by calling prime_isolated(50, 100)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
