How can I make MATLAB recognize multiples?

16 ビュー (過去 30 日間)
Ali Almakhmari
Ali Almakhmari 2023 年 1 月 20 日
回答済み: Jiri Hajek 2023 年 1 月 20 日
I am trying to write line(s) of code that can recognize if a given number is an integer multiple of another given number. For example: if I want to check if the user's input are integer multiples of 5, then 5, 10, 15, 20, 25, 30, etc., are all answers for this. But 2,3,4,6,7,etc. are not. The user can specificy the wanted number to check and the multiple to check with.

採用された回答

Jiri Hajek
Jiri Hajek 2023 年 1 月 20 日
HI, you can utilize the rem or mod functions, which give you remainder after division. There are slight differences between the two, but for your case of integere numbers you can use any of them.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by