Why MatLab gives me incorrect result for prime number?

3 Ansichten (letzte 30 Tage)
Felipe Alcalde
Felipe Alcalde am 11 Jan. 2018
Bearbeitet: Felipe Alcalde am 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?

Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by