# Receiving no output when executing this code

Today I was trying to compute the value of a function in one point ($f(3594641)$) using Mathematica. The main difficulty it has is that it requires both calculating primorials (product of primes) and integrating them.

At first, when I tried to execute it, I received "RecursionLimit" error, so I added a line to solve it. My problem now is that Mathematica basically does not give me any output. At first, it says "Runing...", but after a couple of minutes, that message disappears without leaving any output.

This is the code:

 Primorial[0] := 1;
Primorial[1] := 2;
Primorial[n_] := Primorial[n] = Prime[n] Primorial[n - 1];
ChebyshevTheta[n_] := Log[Primorial[PrimePi[n]]];

Inte1[n_] := Log[n]/Log[n + 1] - Log[n - 1]/Log[n];

Inte2[n_] := Sum[ChebyshevTheta[x]*Inte1[x], {x, 2, n}];

Inte3[n_] := N[Integrate[
y * (-(Log[-1 + y])/(y (Log[y])^2) +
1/((-1 + y) Log[y])),
{y, 2, n}], 15];

$RecursionLimit = 10^12; N[(Inte2[3594641] - Inte3[3594641]), 15]  Any help? Thank you very much • There are just physical limits on any real system.$10^12$recursions, and you want to cache all the values in between? Unless you have a supercomputer at home, I would say no surprise it crashes your kernel. – Felix Feb 11 '17 at 19:13 • @Felix Thank you for your comment. Then, would it be impossible for me to compute that value? Wolfram Cloud gives similar error. Isn't there any other option? – user3141592 Feb 11 '17 at 19:27 ## 2 Answers In addition to the non-recursive definition provided by @ngenisis, you can also speed things up considerably by using numerical summation and integration: ClearAll[primorial, chebyshevTheta, inte1, inte2, inte3] primorial[0] = 1; primorial[n_] := Times @@ Prime@Range[n] chebyshevTheta[n_] := Log[primorial[PrimePi[n]]] inte1[n_] := Log[n]/Log[n + 1] - Log[n - 1]/Log[n] inte2[n_?NumericQ] := NSum[chebyshevTheta[x]*inte1[x], {x, 2, n}] inte3[n_?NumericQ] := NIntegrate[ y*(-(Log[-1 + y])/(y (Log[y])^2) + 1/((-1 + y) Log[y])), {y, 2, n}]  Note the use of NSum and NIntegrate; since those functions only work on numerical values, it is best to make sure that evaluation of inte2 and inte3 is only attempted when their input is explicitly numerical, hence the NumericQ condition in the definition. inte3[50000000] (* Out: 5.43051 *)  As a stylistic consideration, it is common practice not to give your own functions names starting with uppercase characters; those are best left for built-ins. • Thank you very much for your interest. When I try to execute that piece of code, I get the error "range: Range specification in Range[PrimePi[x]] does not have appropriate bounds." What am I doing wrong? I copy-pasted your code. Any ideas? – user3141592 Feb 11 '17 at 21:16 • Use IntegerQ to ensure primorial is not evaluated symbolically: primorial[n_?IntegerQ] := Times @@ Prime@Range[n] – Felix Feb 11 '17 at 21:44 • @Felix Sorry for my persistance, but I am now getting the error "NIntegrate was unable to convert PrimePi[NIntegrateStrategiesDumprv49683] to Piecewise because the required number 256351 of piecewise cases sought exceeds the internal limit$MaxPiecewiseCases = 100" What can I do? Thank you. – user3141592 Feb 11 '17 at 22:18

Try defining Primorial without recursion:

Primorial @ 0   = 1;
Primorial [n_] := Times @@ Prime @ Range[n];


On the cloud, this computed ChebsyshevTheta[3594641]*Inte1[3594641] in 0.000026 seconds, so I think this should be good enough for Inte2 on desktop. You may also consider using N for Inte1 and Inte2.

• I am getting the error "Range specification in Range[PrimePi[x]] does not have appropiate bounds". What am I doing wrong? – user3141592 Feb 11 '17 at 19:58