Integer sequence, possible closed form solution

94 Views Asked by At

I was redirected to ask on Math.SE if there may be a closed form solution to find values in this sequence.

Original question: https://mathematica.stackexchange.com/questions/201631/integer-sequence-and-ram-limits

I am trying to calculate the set of unique differences in a sequence, however the sequence grows fast and I hit the RAM limit of my PC for nthPrimeToUse = 11. For nthPrimeToUse 1 to 10 the output of Length[abc4] is: 0,1,2,3,5,7,10,13,16,20,... I am trying to find at least a few more terms if possible.

Here is the Mathematica code: Updated code: (outputs: 0,1,2,3,5,7,10,13,16,20 for nthPrimeToUse=1 to 10)

nthPrimeToUse = 5; 
primeNumber = Prime[nthPrimeToUse];
Primorial[n_] := Times @@ Prime[Range[n]]
PrimorialToUse = Primorial[nthPrimeToUse - 1];
range = PrimorialToUse*primeNumber*2;
x = Select[(primeNumber) Range@range, GCD[#, PrimorialToUse ] == 1 &];
x = x/primeNumber;
valuesDivisibleByPrime = {}
For[i = 0, i < Length[x], i++,
 If[GCD[x[[i]], primeNumber] != 1,
  AppendTo[valuesDivisibleByPrime, x[[i]]]
  ]
 ]
x = Differences[valuesDivisibleByPrime] ;
CountDistinct[x]

This code is faster, possibly equivalent to the above code for nthPrimeToUse > 3 (outputs: 0,0,1,3,5,7,10,13,16,20 for nthPrimeToUse=1 to 10)

nthPrimeToUse = 5;
primeNumber = Prime[nthPrimeToUse];
Primorial[n_] := Times @@ Prime[Range[n]]
PrimorialToUse = Primorial[nthPrimeToUse - 1];

coprimesOfPrimorial = 
Select[Range[1, PrimorialToUse], CoprimeQ[PrimorialToUse, #] &];
abc1 = Length[coprimesOfPrimorial];
abc2 = Differences[coprimesOfPrimorial];
abc3 = CountDistinct[abc2];
abc4 = DeleteDuplicates[abc2];
abc4 = abc4*primeNumber;
Sort[abc4]
Length[abc4]

Thanks.

cheers, Jamie