X^n calculation
이전 댓글 표시
Calculate the n th power of a given number with loops
답변 (1개)
Asmit Singh
2021년 6월 1일
%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
James Tursa
2021년 6월 1일
@Asmit Singh Please do not post complete answers to homework questions.
카테고리
도움말 센터 및 File Exchange에서 MATLAB에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!