Question: Matlab: Use the built-in primes function to create a vector of all primes below the input N. Now use a for loop to multiply adjacent
Matlab:
Use the built-in primes function to create a vector of all primes below the input N. Now use a for loop to multiply adjacent values together and output this vector from your function.
For example, if N is 10, then your function will create a vector of all primes below 10 and multiply each adjacent value. In this example, the prime vector is equal to:
[2, 3, 5, 7]
Your calculation would be:
2*3 3*5 5*7
And your final output vector would be:
[6, 15, 35]
A. Write out, in comments, how you will loop through the primes vector.
B. Set up your function, naming it primes_loop.m.
C. Complete the function and test it in todays script using an N value of 15.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
