X^n calculation

12 ビュー (過去 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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by