Finding maximum integer between [100,200] divisible by 21?

11 ビュー (過去 30 日間)
Peyman Heidarian
Peyman Heidarian 2018 年 11 月 21 日
回答済み: Jan 2018 年 11 月 21 日
I want use "for" and "while" to get the result.
  1 件のコメント
Jan
Jan 2018 年 11 月 21 日
This sounds like a homework question. Using for and while will be hard, but one or the other is smart enough. Please post, what you have tried so far and ask a specific question. The forum will not solve your homework. You need one line of code only, therefore it is hard to give some hints without posting the complete solution.

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

回答 (2 件)

Torsten
Torsten 2018 年 11 月 21 日
n = 200 - mod(200,21)

Jan
Jan 2018 年 11 月 21 日
Hints:
  • The vector of number from 100 to 200:
100:200
  • Dividable by 21:
mod(x, 21) == 0
  • The maximum value can be found by the max() command, or by find(y, 1, 'last')

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by