フィルターのクリア

how to iterate powers? example 5^5 = 5*5*5*5*5

2 ビュー (過去 30 日間)
Ricardo David
Ricardo David 2022 年 8 月 25 日
回答済み: Chunru 2022 年 8 月 25 日
%potencia
x^n==input("introducir numero");
disp(x^n)
while x^n<n
x^n=(x^n)^2
end

回答 (1 件)

Chunru
Chunru 2022 年 8 月 25 日
% potencia
% x=input("introducir numero");
x = 5;
n=1;
xn = 1;
while n<=5
xn = xn * x;
fprintf("x^%d = %d\n", n, xn);
n = n+1;
end
x^1 = 5 x^2 = 25 x^3 = 125 x^4 = 625 x^5 = 3125

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by