How to find the largest factor of a number using while loops?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Evan Charlesworth
el 11 de Nov. de 2018
Respondida: Bruno Luong
el 11 de Nov. de 2018
factor cannot be the number we are testing
1 comentario
Respuesta aceptada
Bruno Luong
el 11 de Nov. de 2018
largestfactor=floor(n/2);
while largestfactor>0
if mod(n,largestfactor)==0
break
end
largestfactor = largestfactor-1;
end
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!