필터 지우기
필터 지우기

Error in If else statement

조회 수: 2 (최근 30일)
lilly lord
lilly lord 2020년 9월 27일
댓글: lilly lord 2020년 9월 27일
Hi I am getting error in if else statement but dont know where is the mistake.
Points=[];
for i=1:257
if i == 16 & i == 136
a=mod(i*(modInv(32*i+1,n)),n);
else
a=mod(i*(modInv(16*i+1,n)),n);
end
b(i)=mod(a,n);
end
Points=[b];
For i= 16 or 136 it should execute line3 but it gives NaN at i=16 and i=136
If anyone can help me what is the mistake
Correct answer for i=16 is 241 and for i=136 is 120

채택된 답변

Alan Stevens
Alan Stevens 2020년 9월 27일
You probably mean
if i == 16 || i == 136
as i can't be both 16 and 136 at the same time!
  댓글 수: 1
lilly lord
lilly lord 2020년 9월 27일
Thanks for the correction.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by