フィルターのクリア

i want factorial matrix

3 ビュー (過去 30 日間)
Emre Metin
Emre Metin 2020 年 5 月 22 日
コメント済み: Image Analyst 2020 年 5 月 22 日
i want to create a matrix which includes all numbers from 1 to n. n is given by user so i don't know n. In other words a matrix which i want to create must include n! numbers. n, n-1, n-2... n-(-n-1).

採用された回答

Image Analyst
Image Analyst 2020 年 5 月 22 日
編集済み: Image Analyst 2020 年 5 月 22 日
Did you look up factorial in the help?
>> n = input('Enter n : ')
Enter n : 8
n =
8
>> output = factorial(n : -1 : 1)
output =
40320 5040 720 120 24 6 2 1
  3 件のコメント
Emre Metin
Emre Metin 2020 年 5 月 22 日
but this is okey i understood the answer thank you so much :D
Image Analyst
Image Analyst 2020 年 5 月 22 日
I don't see how [8 7 6 5 4 3 2 1] has anything at all to do with factorial. If you want that you can simply do
output = n : -1 : 1;
but that's just super basic MATLAB stuff.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by