필터 지우기
필터 지우기

i want to make program that find prime number

조회 수: 1 (최근 30일)
Ann Lee
Ann Lee 2022년 4월 29일
댓글: Ann Lee 2022년 5월 2일
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

채택된 답변

Image Analyst
Image Analyst 2022년 4월 29일
Instead of
endfunction
use
end
Instead of
endfor
use
end
  댓글 수: 5
Image Analyst
Image Analyst 2022년 4월 30일
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 2022년 5월 2일
oh okay i'll use matlab program instead of octave~

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Steven Lord
Steven Lord 2022년 4월 29일
MATLAB already has a function for this. See the isprime function.

카테고리

Help CenterFile Exchange에서 Octave에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by