X^n calculation

조회 수: 11 (최근 30일)
ceren uçak
ceren uçak 2021년 6월 1일
댓글: James Tursa 2021년 6월 1일
Calculate the n th power of a given number with loops

답변 (1개)

Asmit Singh
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
James Tursa 2021년 6월 1일
@Asmit Singh Please do not post complete answers to homework questions.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by