I've the following code:
Block[{Part},
With[{x = #[[1]] + 1, y = #[[2]]},
Hold[Pick[#[[All, 1 ;; 2]], #[[All, -1]], 0] &@
NestList[
With[{n = Sqrt[1 + 12 x^2 (1 + x)]},
If[FractionalPart@n == 0, {x, Round[n], 0}, {x, y,
1}]] &, {Floor@CubeRoot@10^9, 1}, 10^(10)]]]] //
ReleaseHold // AbsoluteTiming
But this code gives an error message (SystemException["MemoryAllocationFailure"]), how can I solve it? And how can I speed up this calculation
Partautomatically looks suspect. – Daniel Lichtblau Jan 12 '20 at 16:54NestListis 10^10. That means a table of that length is preallocated. Which probably explains the memory exception. If brute-force is the only known approach for this computation, I will suggest instead usingDo,Sow, andReap. – Daniel Lichtblau Jan 12 '20 at 17:07NestListwill attempt to create a $10^{10} \times 3` array, which takes over 200 GB to store (if packed). I think you've gone beyond machine limits. – Michael E2 Jan 12 '20 at 17:20Floor@CubeRoot@307.was to ensure thatx^3 - 307was positive (the firstxisFloor@CubeRoot@307. + 1), because in that problem, we haven = Sqrt[x^3 - 307.]. In your problem, the corresponding starting point will be the least value ofxthat makes1 + 12 x^2 (1 + x)positive. – Michael E2 Jan 12 '20 at 17:26