How to find the largest factor of a number using while loops?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Evan Charlesworth
am 11 Nov. 2018
Beantwortet: Bruno Luong
am 11 Nov. 2018
factor cannot be the number we are testing
1 Kommentar
Akzeptierte Antwort
Bruno Luong
am 11 Nov. 2018
largestfactor=floor(n/2);
while largestfactor>0
if mod(n,largestfactor)==0
break
end
largestfactor = largestfactor-1;
end
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!