Question: What steps would you take to solve this in Matlab? Write a function called next_prime that takes a scalar positive integer input n. Use a
What steps would you take to solve this in Matlab?
Write a function called next_prime that takes a scalar positive integer input n. Use a while-loop to find and return k, the smallest prime number that is greater than n. Feel free to use the built-in isprime function to verify if the number is a prime or not. Here are some example runs: >> next_prime (2) ans = >> next_prime (8) ans = 3 >> next_prime (12345678) ans 11 12345701 Create a function file named next_prime.m that: Use a while loop to find the number k which is the smallest prime number that is greater than n. - In the script file, Class_21_App.m perform the following tasks: Ask user to input a scalar positive integer. Verify if the number is a positive number; if it is a scalar number; if it is an integer. If the number is not correct, display an error message. Call function next_prime to find the required prime number if the number that the user entered is valid. Use fprintf to display the prime number. Repeat the program until the user chooses to quit. For testing purposes please use the following inputs for the file you submit: Testing Conditions (1) -3; (2) 8.2; (3) [2 5 3]; (4) 2; (5) 12345678
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
