how do you write function divisible(n)?
Afficher commentaires plus anciens
The function has one parameter n. If n is divisible by both 3 and 5, the function returns true. Otherwise returns false.
Réponse acceptée
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);
Catégories
En savoir plus sur Vehicle Dynamics Blockset dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!