필터 지우기
필터 지우기

How could find multiples of a given number N ?

조회 수: 131 (최근 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.

추가 답변 (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 CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by