Effacer les filtres
Effacer les filtres

How could find multiples of a given number N ?

133 vues (au cours des 30 derniers jours)
Neha W
Neha W le 29 Mar 2016
The input is taken from the user.

Réponse acceptée

Torsten
Torsten le 29 Mar 2016
"input" is a multiple of N if and only if mod(input,N)=0.
Best wishes
Torsten.

Plus de réponses (2)

ilker melik
ilker melik le 30 Juil 2020
Modifié(e) : ilker melik le 30 Juil 2020
function c = finding_multipliers(y) % y is the number that you are looking for.
count = 0;
n = 1;
while n < y
if mod(y,n) == 0
count = count + 1;
c(count,1) = n;
end
n = n + 1;
end
This can be a helpful function.
  1 commentaire
Stephen23
Stephen23 le 30 Juil 2020
Modifié(e) : Stephen23 le 30 Juil 2020
A better use of MATLAB:
>> y = 15;
>> v = 2:y/2;
>> c = v(mod(y,v)==0)
c =
3 5
Also read the comments to this answer:

Connectez-vous pour commenter.


RINU BENNY
RINU BENNY le 26 Avr 2022
n=input('enter the number whose multiple is needed'); m=input('enter the range of multiples needed'); for i=0:m if mod(i,n)==0 disp(i); end end

Catégories

En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by