The function has one parameter n. If n is divisible by both 3 and 5, the function returns true. Otherwise returns false.

 채택된 답변

Chandrasekhar
Chandrasekhar 2014년 3월 4일

0 개 추천

function [Res] = divisible(n)
if(rem(n,3)==0 && rem(n,5) == 0)
Res = 1;
else
Res = 0;
end

추가 답변 (1개)

David Sanchez
David Sanchez 2014년 3월 4일

0 개 추천

Re-using the code above, you can do it in a single line:
function [Res] = divisible(n)
Res = (rem(n,3)==0 && rem(n,5) == 0);

카테고리

도움말 센터File Exchange에서 Encryption / Cryptography에 대해 자세히 알아보기

질문:

2014년 3월 4일

답변:

2014년 3월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by