フィルターのクリア

How could find multiples of a given number N ?

133 ビュー (過去 30 日間)
Neha W
Neha W 2016 年 3 月 29 日
回答済み: RINU BENNY 2022 年 4 月 26 日
The input is taken from the user.

採用された回答

Torsten
Torsten 2016 年 3 月 29 日
"input" is a multiple of N if and only if mod(input,N)=0.
Best wishes
Torsten.
  1 件のコメント
Neha W
Neha W 2016 年 3 月 29 日
Thank you Sir

サインインしてコメントする。

その他の回答 (2 件)

ilker melik
ilker melik 2020 年 7 月 30 日
編集済み: ilker melik 2020 年 7 月 30 日
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 件のコメント
Stephen23
Stephen23 2020 年 7 月 30 日
編集済み: Stephen23 2020 年 7 月 30 日
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:

サインインしてコメントする。


RINU BENNY
RINU BENNY 2022 年 4 月 26 日
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

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by