0

I used the following code to found if a specific number is a perfect square:

Clear["Global`*"];
ParallelTable[
  If[IntegerQ[Sqrt[ ...]], ..., Nothing], {..., ..., ...}] //. {} -> 
  Nothing

Mathematice can do this for numbers up to:

$MaxMachineNumber
1.79769*10^308

But my code is way, way too slow. Is there an other way to write the code in Mathematica that will be much faster?

I would accept a recommendation to use another programming language to find if a number is a perfect square for large values (like $10^{12}$ and bigger)? I know that ULLONG_MAX in C++ can handle values up to $18446744073709551615$. But code in C++ is slow for larger values. I also thought about using properties of square numbers in my program, but that means that I also need to compute the values.

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
Jan Eerland
  • 2,001
  • 10
  • 17

0 Answers0