Effacer les filtres
Effacer les filtres

i want to make program that find prime number

1 vue (au cours des 30 derniers jours)
Ann Lee
Ann Lee le 29 Avr 2022
Commenté : Ann Lee le 2 Mai 2022
i made this program, but i couldnt find errors..
and i typed primecheck(11) on command window and i got
>> primefunction(11)
error: 'primefunction' undefined near line 1, column 1
this error..
function primecheck(p)
prime=1;
for d=2:sqrt(p)
if(rem(p,d)==0)
prime=0;
end
endfor
if(prime==1)
disp('the number is prime')
else
disp('the number is not prime')
end
endfunction

Réponse acceptée

Image Analyst
Image Analyst le 29 Avr 2022
Instead of
endfunction
use
end
Instead of
endfor
use
end
  5 commentaires
Image Analyst
Image Analyst le 30 Avr 2022
OK you should probably switch to MATLAB. If you can't now, then maybe when you work for an organization that can afford to pay for it. There are probably Octave forums where you can ask questions.
Ann Lee
Ann Lee le 2 Mai 2022
oh okay i'll use matlab program instead of octave~

Connectez-vous pour commenter.

Plus de réponses (1)

Steven Lord
Steven Lord le 29 Avr 2022
MATLAB already has a function for this. See the isprime function.

Catégories

En savoir plus sur Octave dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by