X^n calculation
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Calculate the n th power of a given number with loops
0 comentarios
Respuestas (1)
Asmit Singh
el 1 de Jun. de 2021
%Number is the base number
number = 5;
ans = 1;
% n is the power to which the number needs to be raised
n = 3;
while(n~=0)
ans = ans*number;
n=n-1;
end
1 comentario
James Tursa
el 1 de Jun. de 2021
@Asmit Singh Please do not post complete answers to homework questions.
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!