cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-8 of 8 results.

A038698 Excess of 4k-1 primes over 4k+1 primes, beginning with prime 2.

Original entry on oeis.org

0, 1, 0, 1, 2, 1, 0, 1, 2, 1, 2, 1, 0, 1, 2, 1, 2, 1, 2, 3, 2, 3, 4, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 3, 2, 3, 2, 3, 4, 3, 4, 3, 4, 3, 2, 3, 4, 5, 6, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 3, 4, 3, 4, 5, 4, 3, 4, 3, 4, 3, 2, 3, 4, 3, 4, 5, 4, 3, 2, 1, 2, 1, 2, 1, 2, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 6, 5, 6, 5, 6, 5, 6, 5, 6
Offset: 1

Views

Author

Keywords

Comments

a(n) < 0 for infinitely many values of n. - Benoit Cloitre, Jun 24 2002
First negative value is a(2946) = -1, which is for prime 26861. - David W. Wilson, Sep 27 2002

References

  • Stan Wagon, The Power of Visualization, Front Range Press, 1994, p. 2.

Crossrefs

Cf. A112632 (race of 3k-1 and 3k+1 primes), A216057, A269364.
Cf. A156749 (sequence showing Chebyshev bias in prime races (mod 4)), A199547, A267097, A267098, A267107, A292378.
List of primes p such that a(p) = 0 is A007351. List of primes p such that a(p) < 0 is A199547. List of primes p such that a(p) = -1 is A051025. List of integers k such that a(prime(k)) = -1 is A051024. - Ya-Ping Lu, Jan 18 2025

Programs

  • Maple
    ans:=[0]; ct:=0; for n from 2 to 2000 do
    p:=ithprime(n); if (p mod 4) = 3 then ct:=ct+1; else ct:=ct-1; fi;
    ans:=[op(ans),ct]; od: ans; # N. J. A. Sloane, Jun 24 2016
  • Mathematica
    FoldList[Plus, 0, Mod[Prime[Range[2,110]], 4] - 2]
    Join[{0},Accumulate[If[Mod[#,4]==3,1,-1]&/@Prime[Range[2,110]]]] (* Harvey P. Dale, Apr 27 2013 *)
  • PARI
    for(n=2,100,print1(sum(i=2,n,(-1)^((prime(i)+1)/2)),","))
    
  • Python
    from sympy import nextprime; a, p = 0, 2; R = [a]
    for _ in range(2,88): p=nextprime(p); a += p%4-2; R.append(a)
    print(*R, sep = ', ')  # Ya-Ping Lu, Jan 18 2025

Formula

a(n) = Sum_{k=2..n} (-1)^((prime(k)+1)/2). - Benoit Cloitre, Jun 24 2002
a(n) = (Sum_{k=1..n} prime(k) mod 4) - 2*n (assuming that x mod 4 > 0). - Thomas Ordowski, Sep 21 2012
From Antti Karttunen, Oct 01 2017: (Start)
a(n) = A267098(n) - A267097(n).
a(n) = A292378(A000040(n)).
(End)
From Ridouane Oudra, Nov 04 2024: (Start)
a(n) = Sum_{k=2..n} i^(prime(k)+1), where i is the imaginary unit.
a(n) = Sum_{k=2..n} sin(3*prime(k)*Pi/2).
a(n) = Sum_{k=2..n} A163805(prime(k)).
a(n) = Sum_{k=2..n} A212159(k). (End)
a(n) = a(n-1) + prime(n) (mod 4) - 2, n >= 2. - Ya-Ping Lu, Jan 18 2025

A270190 Numbers n for which prime(n+1)-prime(n) is a multiple of three.

Original entry on oeis.org

9, 11, 15, 16, 18, 21, 23, 32, 36, 37, 39, 40, 46, 47, 51, 54, 55, 56, 58, 67, 71, 73, 74, 76, 84, 86, 91, 96, 97, 99, 100, 102, 103, 105, 107, 108, 110, 111, 114, 118, 119, 121, 123, 129, 130, 133, 139, 160, 161, 164, 165, 167, 168, 170, 174, 179, 180, 184, 185, 187, 188, 194, 195, 197, 199, 200, 202, 203, 205, 208, 210
Offset: 1

Views

Author

Antti Karttunen, Mar 16 2016

Keywords

Comments

Numbers n for which A001223(n) = 0 modulo 3.
See comments in A270189 and A269364.
Equivalently, numbers n for which prime(n+1)-prime(n) is a multiple of six. See A276414 for runs of increasing length of consecutive integers. - M. F. Hasler, Sep 03 2016

Examples

			9 is present as the difference between A000040(9+1) = 29 and A000040(9) = 23 is 6, a multiple of three.
		

Crossrefs

Complement: A270189.
Positions of zeros in A137264.
Left inverse: A269850.

Programs

  • Mathematica
    Select[Range@ 210, Divisible[Prime[# + 1] - Prime@ #, 3] &] (* Michael De Vlieger, Mar 17 2016 *)
    PrimePi/@Select[Partition[Prime[Range[350]],2,1],Divisible[#[[2]]-#[[1]], 3]&][[All,1]] (* Harvey P. Dale, Jul 11 2017 *)
  • PARI
    isok(n) = ((prime(n+1) - prime(n)) % 3) == 0; \\ Michel Marcus, Mar 17 2016

Formula

Other identities. For all n >= 1:
a(n) = A269399(n) + 6.
A269850(a(n)) = n.

A137264 Prime number gaps read modulo 3.

Original entry on oeis.org

1, 2, 2, 1, 2, 1, 2, 1, 0, 2, 0, 1, 2, 1, 0, 0, 2, 0, 1, 2, 0, 1, 0, 2, 1, 2, 1, 2, 1, 2, 1, 0, 2, 1, 2, 0, 0, 1, 0, 0, 2, 1, 2, 1, 2, 0, 0, 1, 2, 1, 0, 2, 1, 0, 0, 0, 2, 0, 1, 2, 1, 2, 1, 2, 1, 2, 0, 1, 2, 1, 0, 2, 0, 0, 1, 0, 2, 1, 2, 1, 2, 1, 2, 0, 1, 0, 2, 1, 2, 1, 0, 2, 1, 2, 1, 0, 0, 2, 0, 0, 1, 0
Offset: 1

Views

Author

Noel H. Patson (n.patson(AT)cqu.edu.au), Mar 12 2008

Keywords

Comments

Conjecture: The only digit that is repeated in the sequence is 0 except for n=2 and n=3 where 2 repeats. So 1 may be followed by 2 or 0; 2 may be followed by 1 or 0; 0 may be followed by 0 or 1 or 2. this has been confirmed for the first million prime gaps.
The conjecture is true, because any three numbers whose differences are (1, 1) or (2, 2) will form a complete residue system modulo 3, and hence one of them will be a multiple of 3. - Karl W. Heuer, Mar 16 2016
See comments at A269364. - Antti Karttunen, Mar 17 2016

Crossrefs

Programs

  • Mathematica
    n=1000;(*The length of the list*) Mod[Differences[Table[Prime[i], {i, n}]], 3]
  • Scheme
    (define (A137264 n) (modulo (A001223 n) 3)) ;; Antti Karttunen, Mar 16 2016

A270189 Numbers n for which (prime(n+1)-prime(n)) is not a multiple of three.

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 13, 14, 17, 19, 20, 22, 24, 25, 26, 27, 28, 29, 30, 31, 33, 34, 35, 38, 41, 42, 43, 44, 45, 48, 49, 50, 52, 53, 57, 59, 60, 61, 62, 63, 64, 65, 66, 68, 69, 70, 72, 75, 77, 78, 79, 80, 81, 82, 83, 85, 87, 88, 89, 90, 92, 93, 94, 95, 98, 101, 104, 106, 109, 112, 113, 115, 116, 117, 120, 122, 124, 125
Offset: 1

Views

Author

Antti Karttunen, Mar 16 2016

Keywords

Comments

See A269364 for the effect of the bias that favors these terms over the terms of A270190.

Crossrefs

Complement: A270190.
Disjoint union of A270191 and A270192.
Positions of 1's and 2's in A137264.
Left inverse: A269849.

Programs

  • Mathematica
    Select[Range@ 125, Mod[Prime[# + 1] - Prime@ #, 3] != 0 &] (* Michael De Vlieger, Mar 17 2016 *)
  • PARI
    isok(n) = ((prime(n+1) - prime(n)) % 3) != 0; \\ Michel Marcus, Mar 17 2016

Formula

Other identities. For all n >= 1:
A269849(a(n)) = n.

A269849 a(n) = number of integers k <= n for which prime(k+1)-prime(k) is not a multiple of three.

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 11, 12, 12, 12, 13, 13, 14, 15, 15, 16, 16, 17, 18, 19, 20, 21, 22, 23, 24, 24, 25, 26, 27, 27, 27, 28, 28, 28, 29, 30, 31, 32, 33, 33, 33, 34, 35, 36, 36, 37, 38, 38, 38, 38, 39, 39, 40, 41, 42, 43, 44, 45, 46, 47, 47, 48, 49, 50, 50, 51, 51, 51, 52, 52, 53, 54, 55, 56, 57, 58, 59, 59, 60
Offset: 1

Views

Author

Antti Karttunen, Mar 16 2016

Keywords

Comments

a(n) = number of terms of A270189 <= n, the least monotonic left inverse of A270189.
See comments at A269364.

Crossrefs

Programs

  • Mathematica
    Table[Count[Select[Range@ 125, Mod[Prime[# + 1] - Prime@ #, 3] != 0 &], k_ /; k <= n], {n, 85}] (* Michael De Vlieger, Mar 17 2016 *)
    Accumulate[If[Mod[#,3]==0,0,1]&/@Differences[Prime[Range[90]]]] (* Harvey P. Dale, Apr 15 2024 *)
  • PARI
    a(n) = sum(k=1, n, ((prime(k+1) - prime(k)) % 3) != 0); \\ Michel Marcus, Mar 18 2016

Formula

Other identities. For all n >= 1:
a(A270189(n)) = n.

A270434 a(n) = A270432(n) - A270433(n).

Original entry on oeis.org

1, 2, 3, 4, 5, 4, 3, 4, 5, 6, 5, 6, 7, 6, 5, 6, 7, 6, 5, 6, 5, 4, 3, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 10, 9, 10, 11, 10, 11, 12, 13, 14, 13, 12, 11, 10, 9, 10, 11, 12, 11, 12, 13, 12, 11, 10, 9, 10, 9, 8, 7, 8, 7, 8, 9, 8, 7, 8, 9, 8, 7, 6, 5, 6, 7, 6, 7, 6, 5, 6, 7, 8, 7, 6, 7, 6, 5, 4, 3, 4, 3, 2, 3, 2, 1, 0, 1, 2
Offset: 1

Views

Author

Antti Karttunen, Mar 17 2016

Keywords

Comments

The first negative term occurs at a(223) = -1.
After a(2457) = -1 the sequence dips next time to the negative side at n=218351.
No other negative terms after a(2346395) = -1 in range 1 .. 2^25.
In range 1..(2^25) the maximum value is a(23963418) = 8326 and there are 1252224 negative terms in that range (less than 4%).

Crossrefs

Cf. A270435 (positions of zeros).
Cf. also A038698, A269364.

Programs

  • Mathematica
    nn = 200; f[n_] := (Times @@ Power[If[# == 1, 1, NextPrime@ #] & /@ First@ #, Last@ #] + 1)/2 &@ Transpose@ FactorInteger@ n; g[n_] := Times @@ Power[If[# == 1, 1, NextPrime[#, -1]] & /@ First@ #, Last@ #] &@ Transpose@ FactorInteger[2 n - 1]; s = Select[Range@ nn, Xor[EvenQ@ f@ #, OddQ@ g@ #] &]; t = Select[Range@ nn, Xor[EvenQ@ f@ #, EvenQ@ g@ #] &]; Table[Count[s, k_ /; k <= n] - Count[t, k_ /; k <= n], {n, nn/2}] (* Michael De Vlieger, Mar 17 2016 *)
  • PARI
    default(primelimit, 2^30);
    A003961(n) = my(f = factor(n)); for (i=1, #f~, f[i, 1] = nextprime(f[i, 1]+1)); factorback(f); \\ From Michel Marcus
    A048673(n) = (A003961(n)+1)/2;
    A064989(n) = {my(f); f = factor(n); if((n>1 && f[1,1]==2), f[1,2] = 0); for (i=1, #f~, f[i,1] = precprime(f[i,1]-1)); factorback(f)};
    A064216(n) = A064989((2*n)-1);
    t=0; for(n=1,2^25,if(!((A048673(n)+A064216(n))%2),t++,t--);write("b270434.txt", n, " ", t));
    
  • Scheme
    (define (A270434 n) (- (A270432 n) (A270433 n)))

Formula

a(n) = A270432(n) - A270433(n).

A269850 a(n) = number of integers k <= n for which prime(k+1)-prime(k) is a multiple of three.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 2, 2, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 9, 10, 10, 11, 12, 12, 12, 12, 12, 12, 13, 14, 14, 14, 14, 15, 15, 15, 16, 17, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 22, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 26, 26, 26, 26, 26, 27
Offset: 1

Views

Author

Antti Karttunen, Mar 16 2016

Keywords

Comments

a(n) = number of terms of A270190 <= n, the least monotonic left inverse of A270190.
See comments at A269364.

Crossrefs

Programs

  • Mathematica
    Table[Count[Select[Range@ 125, Divisible[Prime[# + 1] - Prime@ #, 3] &], k_ /; k <= n], {n, 91}] (* Michael De Vlieger, Mar 17 2016 *)
  • PARI
    a(n) = sum(k=1, n, ((prime(k+1) - prime(k)) % 3) == 0); \\ Michel Marcus, Mar 18 2016

Formula

Other identities. For all n >= 1:
a(A270190(n)) = n.

A272043 a(n) is the shyest prime in base n.

Original entry on oeis.org

2, 3, 31, 13, 523, 31, 3833, 491, 5483, 523, 18149, 661, 44657, 3833, 18869, 7333, 165479, 5483, 153953, 20411, 129127, 18149, 538651, 7079, 932257, 44657, 417037, 52639, 2223773, 18869, 3124217, 175229, 1993763, 165479, 2794811, 50461, 8678963, 153953
Offset: 1

Views

Author

Andy Martin, Apr 18 2016

Keywords

Comments

Terminology: consider pairs of final digits of consecutive primes (a,b). Then of all pairs (3,1) is found last in the prime sequence, corresponding to (523, 541). This is termed the shyest pair, with 523 the shyest prime.
Consider final digit pairs (a,b) of consecutive primes.
There are three unique pairs: (2, 3) (3, 5) (5, 7)
For the remaining 16 pairs, record the first observed primes corresponding to the pair:
Initial prime -- Second prime (mod 10) ---
(mod 10) 1 3 7 9
1 181,191 11, 13 31, 37 401,409
3 523,541 283,293 13, 17 23, 29
7 7, 11 47, 53 337,347 17, 19
9 29, 31 19, 23 89, 97 139,149
523,541 is the largest pair, thus the last to occur in the sequence of primes. The first member of this pair is the shyest prime, base 10. (Note that if we consider two digit pairs (ab, cd) then 40191937, 40192037 is the shyest pair for base 10.)
For base 3 the table is:
Initial prime Second prime (mod 3)
(mod 3) 0 1 2
0 - - 3,5
1 - 31,37 7,11
2 2,3 5,7 23,29
and 31 is the shyest prime base 3.

Crossrefs

Programs

  • Mathematica
    a[n_] := Block[{g,p,m,q,k, e= First /@ Select[ Tally[ Mod[ Prime@ Range[n* 100], n]], #[[2]] > 50 &], A}, A = Association@ Table[{i,j} -> 0, {i,e}, {j,e}]; g = Length[e]^2; m=p=2; While[g > 0, q = NextPrime@p; k = Mod[{p, q}, n]; If[ Lookup[A, Key@k, 1] == 0, A[k] = 1; g--]; m=p; p=q]; m]; Array[a, 25] (* Giovanni Resta, Apr 19 2016 *)
  • Ruby
    require 'Prime'
    # Ruby Code
    # Generates Hash with first occurrences of all possible pairs (a,b)
    # of final digits for consecutive primes in specified base.
    def gen_hash(h, base)
      last_prime = 2
      iteration = last_found = 0
      Prime.each() do |prime|
        # This check could be improved & may be invalid for bases above 35.
        return if (iteration+=1) > 10000 && iteration > 2 * last_found
        next if prime == 2
        l =  last_prime.to_s(base)[-1]
        p =  prime.to_s(base)[-1]
        if h[[l,p]].nil?
          h[[l,p]] = [last_prime,prime]
          last_found = iteration
        end
        last_prime = prime
      end
    end
    puts "First Prime  Second Prime  Base  Difference  Different  Final Digits In"
    puts "                                                 Pairs    Base Notation"
    puts "          2             3     1           1          1              1 1"
    # For bases above 35 additional programming needed.
    2.upto(35){|base|
      gen_hash(h = Hash.new, base)
      p0 = h.values.sort.last[0]
      p1 = h.values.sort.last[1]
      printf("%11d  %12d  %4d  %10d %10d              %s %s\n",
      p0, p1, base, p1 - p0, h.length, p0.to_s(base)[-1], p1.to_s(base)[-1])
    }

Extensions

a(22)-a(38) from Giovanni Resta, Apr 19 2016
Showing 1-8 of 8 results.