フィルターのクリア

How to find the largest factor of a number using while loops?

2 ビュー (過去 30 日間)
Evan Charlesworth
Evan Charlesworth 2018 年 11 月 11 日
回答済み: Bruno Luong 2018 年 11 月 11 日
factor cannot be the number we are testing
  1 件のコメント
Evan Charlesworth
Evan Charlesworth 2018 年 11 月 11 日
編集済み: madhan ravi 2018 年 11 月 11 日
I've gotten this so far, but don't know where to go from here.
largestfactor=n-1;
while largestfactor>0
if mod(n,largestfactor)==0

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

採用された回答

Bruno Luong
Bruno Luong 2018 年 11 月 11 日
largestfactor=floor(n/2);
while largestfactor>0
if mod(n,largestfactor)==0
break
end
largestfactor = largestfactor-1;
end

その他の回答 (0 件)

カテゴリ

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