\\gapcount is a list of frequency of (even) gaps so far cumulative. \\Place i of the list has gap 2i. As we start at prime 3, difference 1 isn't seen. \\freqgap is a list of frequence of (even) gaps so far for each prime. \\ - g is the gap between prime i and the next larger prime. \\ - imax denotes the index of the largest frequency of prime gaps. \\ - gmax records the highest frequency of gaps so far. \\ - passes records at which primes imax changed. \\ - is24 records primes for which frequence of gap 2 and of gap 4 \\are the same directly after a gap of 2 or of 4. \\ -ordergap is the list in which the order of existing primegaps appear for the first time (A014320) upto(n) = {my(gapcount=List(),passes=List(),gmax = 0,imax = 0,is24 = List(),ordergap = List([1]), freqgap = List([1])); forprime(i=3,n, \\compute the gap g = nextprime(i+1) - i; \\ add the neccesare elements to the list for new gaps (if any). for(i=#gapcount+1,g\2,listput(gapcount,0)); \\add 1 to the place of the current gap. gapcount[g\2]++;print(i" "gapcount); \\gap g occurs for the a(n)-th time. listput(freqgap,gapcount[g\2]); \\if the gap occurs for the first time, put it in ordergap if(gapcount[g\2]==1,listput(ordergap,g)); \\see if some gap occurs more often now. If so, put the prime \\in the list 'passes' if(gapcount[g\2] > gmax,gmax = gapcount[g\2];if(imax!=g\2,listput(passes,i);imax=g\2)); \\see if, after a gap of 2 or 4, the frequency of those gaps is the same. if(g<6&&#gapcount>1,if(gapcount[1]==gapcount[2],listput(is24,i))); );\\freqgap=vector(min(1000,#freqgap),i,freqgap[i]); \\print("primegap(n) occured for the a(n)-th time: ");print(freqgap); print("gaps occured this often upto next prime larger than n: ");print(gapcount); print("passes at: ");print(passes); print("frequency of gaps 2 and 4 equal at: ");print(is24); print("gaps upto "n" occur for the first time in the following order: ");print(ordergap); [gapcount,is24,passes,ordergap] }