how do you write function divisible(n)?
25 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
John locke
le 4 Mar 2014
Réponse apportée : David Sanchez
le 4 Mar 2014
The function has one parameter n. If n is divisible by both 3 and 5, the function returns true. Otherwise returns false.
0 commentaires
Réponse acceptée
Chandrasekhar
le 4 Mar 2014
function [Res] = divisible(n)
if(rem(n,3)==0 && rem(n,5) == 0)
Res = 1;
else
Res = 0;
end
0 commentaires
Plus de réponses (1)
David Sanchez
le 4 Mar 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 commentaires
Voir également
Catégories
En savoir plus sur Encryption / Cryptography 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!