Why MatLab gives me incorrect result for prime number?

4 ビュー (過去 30 日間)
Felipe Alcalde
Felipe Alcalde 2018 年 1 月 11 日
編集済み: Felipe Alcalde 2018 年 1 月 11 日
The function isprime() gives correct result for "small" numbers:
isprime(2^31-1) TRUE
BUT it gives incorrect result for larger numbers that are proved to be prime:
isprime(2^61-1) FALSE (but should be true)
WHY??
OK, I guess it is because I am trying to use a bigger number than Matlab can handle. But then, why Matlab does not show any error? and how can I check if a number this big is prime using MatLab?

回答 (0 件)

カテゴリ

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