X^n calculation
조회 수: 11 (최근 30일)
이전 댓글 표시
Calculate the n th power of a given number with loops
댓글 수: 0
답변 (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
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!