Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Matlab function, called testprime, that takes one input argument and uses a for - loop and rem function to check whether its argument

Write a Matlab function, called testprime, that takes one input argument and uses a for-loop and rem function to check whether its argument is a prime number. testprime(x) should return 1 if x is a prime number and 0 otherwise.
Your testprime function must behave as shown below:
>> help testprime
testprime checks if its argument is a prime
testprime(x) is 1 if x is a prime, 0 otherwise.
Author:
>> testprime(12)
ans =
logical
0
>> testprime(7)
ans =
logical
1
>>
Hint: To get a logical 1 and logical 0 as output of your function, see help true and help false
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

0130913677, 978-0130913678

More Books

Students also viewed these Databases questions

Question

8. Describe the steps in the development planning process.

Answered: 1 week ago