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-10 of 11 results. Next

A064940 Values of k for which A065358(k) is 0.

Original entry on oeis.org

0, 2, 6, 34, 38, 42, 50, 54, 78, 86, 90, 106, 110, 114, 834, 842, 1390, 1406, 1410, 1470, 1578, 1586, 1650, 1662, 1842, 1850, 3382, 3490, 3506, 3514, 3518, 3546, 3658, 3690, 3718, 3746, 3778, 3818, 3822, 3842, 3850, 3854, 3870, 3898, 3938, 3946, 3986, 3990
Offset: 1

Views

Author

Jason Earls, Oct 31 2001

Keywords

Crossrefs

Programs

  • Maple
    m:= -1:
    t:= 0:
    Res:= 0,2:
    for i from 3 to 5*10^7 by 2 do
      if isprime(i) then m:= -m fi;
      t:= t+2*m;
      if t = 0 then Res:= Res, i+1 fi;
    od:
    Res; # Robert Israel, Feb 20 2018
  • Mathematica
    A065358 := Table[Sum[(-1)^(PrimePi[k]), {k,1,n}], {n,0,500}]; Select[Range[300], A065358[[#]] == 0 &] - 1  (* G. C. Greubel, Feb 20 2018 *)
    c = s = 0; k = 1; lst = {0}; While[k < 100000, c = Mod[c + Boole[PrimeQ[k]], 2]; s = s + (-1)^c; If[s == 0, AppendTo[lst, k]]; k++]; lst (* Robert G. Wilson v, Feb 20 2018 *)
  • PARI
    { n=s=0; for (m=1, 10^9, s+=(-1)^primepi(m); if (s==0, write("b064940.txt", n++, " ", m); if (n==150, return)) ) } \\ Harry J. Smith, Sep 30 2009
    
  • Python
    from sympy import nextprime
    A064940_list, p, d, n, r = [], 2, -1, 0, False
    while n <= 10**6:
        pn, k = p-n, d if r else -d
        if 0 < k <= pn:
            A064940_list.append(n+k-1)
        d += -pn if r else pn
        r, n, p = not r, p, nextprime(p) # Chai Wah Wu, Feb 21 2018

Extensions

Initial term 0 added by N. J. A. Sloane, Feb 20 2018

A064973 Values for which A065358 is larger than any preceding term.

Original entry on oeis.org

1, 4, 9, 10, 15, 16, 21, 22, 123, 124, 125, 126, 135, 136, 141, 142, 143, 144, 145, 146, 147, 148, 153, 154, 155, 156, 185, 186, 187, 188, 189, 190, 195, 196, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 343, 344, 345, 346, 351, 352, 365, 366, 387, 388
Offset: 1

Views

Author

Jason Earls, Oct 31 2001

Keywords

References

  • Robert G. Wilson v, personal communication.

Programs

  • Mathematica
    a = b = p = s = 0; Do[If[PrimeQ[n], p++ ]; s = s + (-1)^p; If[s > a, a = s; Print[n]], {n, 1, 10^3}]
  • PARI
    { n=b=c=0; for (m=1, 10^9, b+=(-1)^primepi(m); if (b>c, c=b; write("b064973.txt", n++, " ", m); if (n==940, return)) ) } \\ Harry J. Smith, Oct 02 2009

A064993 Values for which A065358 is smaller than any preceding term.

Original entry on oeis.org

35, 36, 837, 838, 1395, 1396, 1397, 1398, 1419, 1420, 1421, 1422, 1491, 1492, 1505, 1506, 1507, 1508, 1509, 1510, 1687, 1688, 1689, 1690, 1691, 1692, 1725, 1726, 1727, 1728, 1729, 1730, 1731, 1732, 1945, 1946, 1947, 1948, 1953, 1954, 1955, 1956, 1957
Offset: 1

Views

Author

Jason Earls, Oct 31 2001

Keywords

References

  • Robert G. Wilson v, personal communication.

Crossrefs

Cf. A064973.

Programs

  • Mathematica
    a = b = p = s = 0; Do[If[PrimeQ[n], p++ ]; s = s + (-1)^p; If[s < b, b = s; Print[n]], {n, 1, 10^3}]
  • PARI
    { n=b=c=0; for (m=1, 10^9, b+=(-1)^primepi(m); if (bHarry J. Smith, Oct 02 2009

Extensions

More terms from Robert G. Wilson v, Nov 03 2001

A299300 Values of k such that A065358(k-1) = 0.

Original entry on oeis.org

1, 3, 7, 35, 39, 43, 51, 55, 79, 87, 91, 107, 111, 115, 835, 843, 1391, 1407, 1411, 1471, 1579, 1587, 1651, 1663, 1843, 1851, 3383, 3491, 3507, 3515, 3519, 3547, 3659, 3691, 3719, 3747, 3779, 3819, 3823, 3843, 3851, 3855, 3871, 3899, 3939, 3947, 3987, 3991
Offset: 1

Views

Author

N. J. A. Sloane, Feb 20 2018

Keywords

Comments

Obtained by adding 1 to the terms of A064940.
Fraile et al. (2017) describe essentially the same sequence as A065358 except with offset 1 instead of 0. So the present sequence gives the values of k so that their version of the Jacob's Ladder sequence has the value 0.
For the first 7730 terms, see the b-file in A064940.

Crossrefs

Programs

  • Mathematica
    A065358:= Table[Sum[(-1)^(PrimePi[k]), {k,1,n}], {n, 0, 500}]; Select[Range[50], A065358[[#]] == 0 &] (* G. C. Greubel, Feb 20 2018 *)
  • Python
    from sympy import nextprime
    A299300_list, p, d, n, r = [], 2, -1, 0, False
    while n <= 10**6:
        pn, k = p-n, d if r else -d
        if 0 < k <= pn:
            A299300_list.append(n+k)
        d += -pn if r else pn
        r, n, p = not r, p, nextprime(p) # Chai Wah Wu, Feb 21 2018

A175851 a(n) = 1 for noncomposite n, a(n) = n - previousprime(n) + 1 for composite n.

Original entry on oeis.org

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

Views

Author

Jaroslav Krizek, Sep 29 2010

Keywords

Comments

Sequence is cardinal and not fractal. Cardinal sequence is sequence with infinitely many times occurring all natural numbers. Fractal sequence is sequence such that when the first instance of each number in the sequence is erased, the original sequence remains.
Ordinal transform of the nextprime function, A151800(1..) = 2, 3, 5, 5, 7, 7, 11, 11, 11, 11, ..., also ordinal transform of A304106. - Antti Karttunen, Jun 09 2018

Crossrefs

Cf. A065358 for another way of visualizing prime gaps.
Cf. A304106 (ordinal transform of this sequence).
Cf. A049711.

Programs

Formula

a(1) = 1, a(n) = n - A007917(n) + 1 for n >= 2. a(1) = 1, a(2) = 1, a(n) = n - A151799(n+1) + 1 for n >= 3.
a(n) = Sum_{i=1..n} floor(pi(i)/pi(n)), for n>1 with pi(n) = A000720(n). - Ridouane Oudra, Jun 24 2024
a(n) = A049711(n+1), for n>1. - Ridouane Oudra, Jul 16 2024

A180714 Sum of the x- and y-coordinates of a point moving in a clockwise spiral.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

A spiral on the simple square grid is constructed starting at (0,0) and walking in the closest self-avoiding clockwise loop: up 1 unit, right 1 unit, down 2 units, left 2 units, up 3 units etc. The step widths in the x-coordinate are 0, 1, 0, -2, 0, 3, ... a signed version of A142150; the step widths in the y-coordinate are 1, 0, -2, 0, 3, ... The x-coordinate after n steps (n>=0) is a signed variant of A002265(n+3), namely 0, 0, 1, 1, -1, -1, 2, 2, -2, -2, 3, ...; the y-coordinate after n steps is 0, 1, 1, -1, -1, 2, 2, ... (n >= 0). The sum of the x- and y-coordinates after n steps (at corners of the spiral) is c(n) = 0, 1, 2, 0, -2, 1, 4, 0, -4, 1, 6, 0, -6, 1, 8, 0, ..., with g.f. -x*(1+x)/( (x-1)*(x^2+1)^2). The current sequence is obtained by recording the sum of the two coordinates at all intermediate positions walking with a stride of 1 along the edges of the spiral, equivalent to showing all interpolating integers between two values of c(n). The first differences a(n+1)-a(n) are two 1's, four -1's, six 1's, eight -1's etc., blocks of +1 and -1 with run lengths increasing by 2. - R. J. Mathar, Jan 22 2011

Examples

			Spiral begins at x=0, y=0, then moves up-right-down-left-up-right-...
a(0)=0+0=0, a(1)=1+0=1, a(2)=1+1=2, a(3)=0+1=1, a(4)=-1+1=0, a(5)=-1+0=-1, ...
		

Crossrefs

A065357 a(n) = (-1)^pi(n) where pi(n) is the number of primes <= n.

Original entry on oeis.org

1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1
Offset: 0

Views

Author

Jason Earls, Oct 31 2001

Keywords

Crossrefs

Programs

  • Mathematica
    (-1)^PrimePi[Range[0,110]] (* Harvey P. Dale, Nov 02 2015 *)
  • PARI
    { for (n=0, 1000, if (n, a=(-1)^primepi(n), a=1); write("b065357.txt", n, " ", a) ) } \\ Harry J. Smith, Sep 30 2009

A278603 A prime mountain: peaks and valleys beyond the origin correspond to prime abscissa (see Comments for precise definition).

Original entry on oeis.org

0, 1, 2, 1, 2, 3, 2, 1, 2, 3, 4, 5, 4, 3, 4, 5, 6, 7, 6, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 4, 5, 4, 3, 2, 1, 0, -1, 0, 1, 2, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, -1, 0, 1, 2, 3, 4, 5, 4, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 6, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3
Offset: 0

Views

Author

Rémy Sigrist, Nov 23 2016

Keywords

Comments

We start with a(0)=0 and a(1)=1, and then the sequence is extended according to these rules:
(1) |a(n+1) - a(n)| = 1 for any n>1,
(2) a(n+1) = a(n-1) iff n is prime.
Is this sequence ultimately positive or ultimately negative or will it change sign indefinitely?
From Ryan Bresler, Jan 04 2021: (Start)
This sequence will contain every integer on "at least one side" of the origin, i.e., it will not have a finite range.
Suppose this sequence has both a finite minimum, R1, and a finite maximum, R2. Since prime gaps become arbitrarily large, we will eventually reach a prime gap g, such that g > R2 - R1. We can see that this prime gap will cause at least one term of this sequence to be outside the interval [R1, R2]. This contradiction shows that all integers on at least one side of the origin will be terms of the sequence.
(End)

Examples

			a(2) is either a(1) + 1 = 2 or a(1) - 1 = 0.
As 1 is not prime, a(2) = a(1+1) != a(1-1) = 0.
Hence, a(2) = 2.
As 2 is prime, a(3) = a(2+1) = a(2-1) = a(1) = 1.
As 3 is prime, a(4) = a(3+1) = a(3-1) = a(2) = 2.
a(5) is either a(4)+1 = 3 or a(4)-1 = 1.
As 4 is not prime, a(5) = a(4+1) != a(4-1) = 1.
Hence, a(5) = 3.
The first terms can be visualized here (peaks correspond to odd-indexed primes, and valleys to even-indexed primes):
.                  /\  ...
.                 /  \/
.            /\  /
.           /  \/
.      /\  /
.   /\/  \/
.  /
.   2  5     11    17
. 0  3   7     13    19
		

Crossrefs

Programs

  • PARI
    y=0; slope=+1; for (x=0, 85, print1 (y ", "); if (isprime(x), slope = -slope); y+=slope)

Formula

a(prime(n)) = prime(1) + Sum_{k=1..n-1} A001223(k)*(-1)^k for any n > 0.
a(n+1) = A065358(n) + 1 for any n >= 0. - Rémy Sigrist, Feb 22 2018

A332939 The number of steps to return to the origin for a walk on a 2D square grid where the walk changes direction to move as close as possible toward the origin after it has taken a prime number of steps; backtracking on its previous step is not allowed.

Original entry on oeis.org

0, 6, 18, 74, 110, 200, 268, 380, 574, 662, 828, 932, 1020, 1134, 1440, 1614, 1734, 1760, 1878, 1954, 2142, 2252, 2394, 2560, 2622, 2672, 2694, 2720, 2802, 2862, 3534, 3702, 3802, 3934, 4020, 4104, 4250, 4462, 4798, 5070, 5530, 5698, 5850, 5870, 5940, 6132, 6222, 6316, 6372
Offset: 0

Views

Author

Scott R. Shannon, Mar 02 2020

Keywords

Comments

Consider a walk on a 2D square grid which starts at the origin and may step in either the positive or negative x and y directions. The walk always continues in the direction of its last step until it has taken a number of steps equal to a prime number. The walk may then change to one of the four available directions so it subsequently moves as closely as possible toward the origin, the only restriction being it cannot choose the direction that will backtrack over its previous step. If the walks' location after a prime number of steps is exactly on one of the axes or on a 45-degree diagonal between the axes then it may choose either of the two equivalent directions as its next step, excluding backtracking.
Given these rules this sequence lists the number of steps the walk has taken when it returns to the origin. All terms are even due to the prime 3 being at relative coordinates (2,1) from the origin, and as all subsequent odd numbers are a multiple of two units away from 3 in the y direction an odd number can never have a zero y coordinate.
For a walk of 100 millions steps the walk returns to the origin 165960 times. The furthest distance from the origin is approximately 207.8 units, after step 20831533. The minimum steps between two origin visits is 6, which occurs at the beginning of the walk, from the first step to the sixth step. The maximum steps between origin visits is 7247, which occurs between steps 41331290 and 41338537.

Examples

			a(0) = 0 as the walk is at the origin after zero steps.
a(1) = 6 as from the origin the walk steps right until the number of steps it takes equals the first prime 2. After one more step upward the total steps equals the next prime 3. Two steps left reaches 5 steps, and then one step down back to the origin, taking 6 steps in all. The first step can be in either of the four symmetrically equivalent directions without changing the total steps back to the origin.
.
          5 -<- 4 -<- 3
          |           |
          \/          /\
          |           |
          * ->- 1 ->- 2   where * is the origin
.
a(2) = 18 as after the sixth step to the origin the walk continues down one more step reaching 7 steps, four steps right reaching 11 steps, two steps up to reach 13 steps, four steps left reaching 17 steps, then one step down back to the origin, giving 18 steps in all.
.
.        17 -<- 16 -<- 15 -<- 14 -<- 13
          |                          |
          \/                         /\
          |                          |
          *(6)                       12
          |                          |
          \/                         /\
          |                          |
          7 ->- 8 ->- 9  ->- 10 ->- 11   where * is the origin and previous step 6.
.
		

Crossrefs

A297158 Ludic ladder sequence: a(n) = Sum_{k=1..n} (-1)^LudicPi(k), where LudicPi(n) = A192512(n)-1 gives the number of Ludic numbers > 1 and <= n.

Original entry on oeis.org

0, 1, 0, 1, 2, 1, 0, 1, 2, 3, 4, 3, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1, 2, 1, 0, -1, -2, -1, 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, -1, -2, -1, 0, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1
Offset: 0

Views

Author

Antti Karttunen, Feb 22 2018

Keywords

Comments

This is an analogous sequence to A065358, but involving Ludic numbers (A003309) instead of primes. Compare the scatter-plots.

Crossrefs

Differs from A065358 for the first time at n=19, where a(19) = 3, while A065358(19) = 5.

Formula

a(n) = Sum_{k=1..n} (-1)^(A192512(k)-1).
Showing 1-10 of 11 results. Next