how do you write function divisible(n)?
25 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
John locke
am 4 Mär. 2014
Beantwortet: David Sanchez
am 4 Mär. 2014
The function has one parameter n. If n is divisible by both 3 and 5, the function returns true. Otherwise returns false.
0 Kommentare
Akzeptierte Antwort
Chandrasekhar
am 4 Mär. 2014
function [Res] = divisible(n)
if(rem(n,3)==0 && rem(n,5) == 0)
Res = 1;
else
Res = 0;
end
0 Kommentare
Weitere Antworten (1)
David Sanchez
am 4 Mär. 2014
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);
0 Kommentare
Siehe auch
Kategorien
Mehr zu Encryption / Cryptography finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!