How to print the first 100 primes including 1 as a vector

14 ビュー (過去 30 日間)
Jerin James
Jerin James 2014 年 5 月 29 日
コメント済み: Jerin James 2014 年 5 月 29 日
i need to print vectors containing all prime numbers less than 100, including 1 as 1 is usually not shown as a prime number in matlab. Thanks

採用された回答

David Sanchez
David Sanchez 2014 年 5 月 29 日
p = [1 primes(100)]
p =
Columns 1 through 19
1 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61
Columns 20 through 26
67 71 73 79 83 89 97
  1 件のコメント
Jerin James
Jerin James 2014 年 5 月 29 日
Thanks so much for the quick response :D

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

その他の回答 (1 件)

Udit Gupta
Udit Gupta 2014 年 5 月 29 日
To print prime numbers less than 100 use
primeNums = [1 primes(100)]
To print first 100 frime numbers use
primeNums = [1 primes(523)]

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by