Calculate the n th power of a given number with loops

답변 (1개)

Asmit Singh
Asmit Singh 2021년 6월 1일

0 개 추천

%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.

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

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

제품

질문:

2021년 6월 1일

댓글:

2021년 6월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by