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-4 of 4 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

A292377 a(1) = 0, and for n > 1, a(n) = a(A252463(n)) + [n == 3 (mod 4)].

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Sep 17 2017

Keywords

Comments

For numbers > 1, iterate the map x -> A252463(x) which divides even numbers by 2 and shifts every prime in the prime factorization of odd n one index step towards smaller primes. a(n) counts the numbers of the form 4k+3 encountered until 1 has been reached. The count includes also n itself if it is of the form 4k+3 (A004767).
In other words, locate the node which contains n in binary tree A005940 and traverse from that node towards the root, counting all numbers of the form 4k+3 that occur on the path.

Crossrefs

Programs

  • Mathematica
    a[1] = 0; a[n_] := a[n] = a[Which[n == 1, 1, EvenQ@ n, n/2, True, Times @@ Power[Which[# == 1, 1, # == 2, 1, True, NextPrime[#, -1]] & /@ First@ #, Last@ #] &@ Transpose@ FactorInteger@ n]] + Boole[Mod[n, 4] == 3]; Array[a, 105]

Formula

a(1) = 0, and for n > 1, a(n) = a(A252463(n)) + floor((n mod 4)/3).
Equivalently, a(2n) = a(n), and for odd numbers n > 1, a(n) = a(A064989(n)) + [n == 3 (mod 4)].
a(n) = A000120(A292383(n)).
Other identities. For n >= 1:
a(n) >= A292376(n).
a(A000040(n)) = A267098(n).
1 + a(n) - A292375(n) = A292378(n).
For n >= 2, a(n) + A292375(n) = A061395(n).

A292375 a(1) = 1, and for n > 1, a(n) = a(A252463(n)) + [n == 1 (mod 4)].

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Sep 17 2017

Keywords

Comments

For numbers > 1, iterate the map x -> A252463(x) which divides even numbers by 2, and shifts every prime in the prime factorization of odd n one index step towards smaller primes. a(n) counts the numbers of the form 4k+1 encountered until 1 has been reached, which is also included in the count. The count includes also n itself if it is of the form 4k+1 (A016813), thus a(1) = 1.
In other words, locate the node which contains n in binary tree A005940 and traverse from that node towards the root, counting all numbers of the form 4k+1 that occur on the path.

Crossrefs

Programs

  • Mathematica
    a[1] = 1; a[n_] := a[n] = a[Which[n == 1, 1, EvenQ@n, n/2, True, Times @@ Power[Which[# == 1, 1, # == 2, 1, True, NextPrime[#, -1]] & /@ First@ #, Last@ #] &@ Transpose@ FactorInteger@ n]] + Boole[Mod[n, 4] == 1]; Array[a, 105] (* Michael De Vlieger, Sep 17 2017 *)
  • PARI
    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)};
    A292375(n) = if(1==n,n,if(!(n%2),A292375(n/2),(if(1==(n%4),1,0)+A292375(A064989(n)))));
    
  • Scheme
    ;; With memoization-macro definec.
    (definec (A292375 n) (if (= 1 n) 1 (+ (if (= 1 (modulo n 4)) 1 0) (A292375 (A252463 n)))))

Formula

a(1) = 1, a(2n) = a(n), and for odd numbers n > 1, a(n) = a(A064989(n)) + [n == 1 (mod 4)].
a(n) = A000120(A292381(n)).
Other identities and observations. For n >= 1:
a(n) >= A292374(n).
a(A000040(n))-1 = A267097(n).
1 + A292377(n) - a(n) = A292378(n).
For n >= 2, a(n) + A292377(n) = A061395(n).
From Antti Karttunen, Apr 22 2022: (Start)
For n >= 2, a(n^2) = A061395(n). [Because A292377(n^2) = 0]
For n >= 1, a(A001248(n)) = n. [See comments in A292583]
(End)

A292584 Compound filter: a(n) = P(A292583(n), A292585(n)), where P(n,k) is sequence A000027 used as a pairing function.

Original entry on oeis.org

1, 2, 5, 2, 8, 5, 13, 2, 4, 8, 19, 5, 25, 13, 9, 2, 32, 4, 41, 8, 12, 19, 51, 5, 16, 25, 5, 13, 72, 9, 85, 2, 18, 32, 14, 4, 98, 41, 26, 8, 112, 12, 128, 19, 8, 51, 145, 5, 46, 16, 33, 25, 180, 5, 18, 13, 49, 72, 200, 9, 220, 85, 13, 2, 24, 18, 242, 32, 60, 14, 265, 4, 288, 98, 8, 41, 19, 26, 313, 8, 4, 112, 339, 12, 33, 128, 62, 19, 365, 8, 25, 51, 84, 145
Offset: 1

Views

Author

Antti Karttunen, Sep 20 2017

Keywords

Comments

From Antti Karttunen, Sep 25 2017: (Start)
Some of the sequences this filter matches to:
For all i, j: a(i) = a(j) => A053866(i) = A053866(j).
For all i, j: a(i) = a(j) => A061395(i) = A061395(j). (also A006530, etc.)
For all i, j: a(i) = a(j) => A292378(i) = A292378(j).
The latter two implications follow simply because:
and, similarly, for n > 1,
and the sum of A292375(n) and A292377(n) is A061395(n) [index of the largest prime dividing n], while A292378 has been defined as 1 + their difference.
The case A053866 follows because of the component A292583, see comments under that entry. (End)

Crossrefs

Cf. also A006530, A061395, A292378 (some of the matched sequences).

Formula

a(n) = (1/2)*(2 + ((A292583(n)+A292585(n))^2) - A292583(n) - 3*A292585(n)).
Showing 1-4 of 4 results.