Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Function to check prime number

1 Ansicht (letzte 30 Tage)
Hong
Hong am 24 Feb. 2024
Geschlossen: John D'Errico am 24 Feb. 2024
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.
>> testprime(12) ans = logical 0
>> testprime(7) ans = logical 1
Hi I've seen old question about prime number, I'm still confused about how to get those I tried to look it up on Youtube and still got the prime number from 0 to that entered number but not check the specific number entered. I'm new to MATLAB and never code before and this is all confusing.
  1 Kommentar
James Tursa
James Tursa am 24 Feb. 2024
Please post what you have done so far and ask specific questions about that code.

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by