How to enter this program?
Mostrar comentarios más antiguos
Hello, I have tried unsuccessfully for a couple hours to enter a program that loops until a number that is even, divisible by both 13 and 16, and whose square root is greater than 120 is found. I have reached a wall, so I have come to ask for help. Would using a while statement be the first step? Please don't solve this problem, I only ask for help getting it going. Yes, this is basic stuff, but I still have little understanding on it.
Respuesta aceptada
Más respuestas (2)
Rick Rosson
el 25 de Oct. de 2014
Editada: Rick Rosson
el 25 de Oct. de 2014
Here is a faster and simpler approach:
a = 0;
while a < 120^2
a = a + 13*16;
end
1 comentario
per isakson
el 26 de Oct. de 2014
Note   "square root is greater than 120"
per isakson
el 26 de Oct. de 2014
Editada: per isakson
el 26 de Oct. de 2014
Try
>> factor( cssm )
ans =
2 2 2 2 2 5 7 13
where cssm is
function ix = cssm()
% chose a start value, which is larger than 120^2 and divisible by 16
ix = 120*120+16;
while ne( mod(ix,13), 0 )
ix = ix + 16;
end
end
Categorías
Más información sobre Programming en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!