필터 지우기
필터 지우기

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 CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by