Why MatLab gives me incorrect result for prime number?

3 vues (au cours des 30 derniers jours)
Felipe Alcalde
Felipe Alcalde le 11 Jan 2018
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?

Réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by