logical operators with while loop
Mostrar comentarios más antiguos
%Find the smallest even integer that is
% divisible by 13 and whose
% square root is greater than 86
clc;
clear;
x=15;
a=rem(x,26);
b=sqrt(x);
while a==0 && b>86
if a==0 && b>86
fprintf('The required number is %d\n',x);
break
else
x=x+1;
end
end
Respuesta aceptada
Más respuestas (2)
David Hill
el 15 de Dic. de 2020
a=7397;
while ~(mod(a,13)==0&&mod(a,2)==0)
a=a+1;
end
x = 2 ;
while ~(mod(x,13) == 0 && sqrt(x)>=86)
x = x+2 ;
end
fprintf('The required number is %d\n',x);
Categorías
Más información sobre MATLAB 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!