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 27 results. Next

A091318 Lengths of runs of 1's in A039702.

Original entry on oeis.org

1, 2, 1, 2, 1, 1, 1, 3, 2, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 2, 1, 2, 1, 2, 1, 4, 1, 1, 3, 2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 3, 2, 1, 4, 2, 1, 1, 2, 2, 3, 1, 1, 3, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 4, 1, 2, 1, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 2, 2, 2, 1, 2, 3, 2, 2, 1, 1, 2, 1, 2, 2, 1, 2, 1, 2, 1, 1, 1, 2, 1, 2, 2, 2, 3, 3, 3
Offset: 1

Views

Author

Enoch Haga, Feb 22 2004

Keywords

Comments

Number of primes congruent to 1 mod 4 in sequence before interruption by a prime 3 mod 4.

Examples

			a(8)=3 because this is the sequence of primes congruent to 1 mod 4: 89, 97, 101. The next prime is 103, a prime 3 mod 4.
		

References

  • Enoch Haga, Exploring prime numbers on your PC and the Internet with directions to prime number sites on the Internet, 2001, pages 30-31. ISBN 1-885794-17-7.

Crossrefs

Programs

  • Mathematica
    t = Length /@ Split[Table[Mod[Prime[n], 4], {n, 2, 400}]]; Most[Transpose[Partition[t, 2]][[2]]] (* T. D. Noe, Sep 21 2012 *)

Formula

Count primes congruent to 1 mod 4 in sequence before interruption by a prime divided by 4 with remainder 3.

A091237 Lengths of runs in A039702.

Original entry on oeis.org

1, 1, 1, 2, 2, 2, 1, 1, 2, 2, 1, 1, 1, 2, 1, 2, 3, 2, 2, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 4, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 2, 1, 1, 1, 2, 2, 1, 2, 4, 1, 1, 1, 1, 2, 3, 7, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2, 1, 1, 3, 2, 2, 2, 1, 3, 4
Offset: 1

Views

Author

N. J. A. Sloane, Feb 22 2004

Keywords

Comments

Lengths of runs, where a run is a succession of primes that are congruent mod 4.
In other words, RUNS transform of A039702. If the two initial 1's are omitted, this is the RUNS transform of A100672. - N. J. A. Sloane, Jan 11 2025

Crossrefs

Programs

  • Mathematica
    Most[Length /@ Split[Table[Mod[Prime[n], 4], {n, 200}]]] (* T. D. Noe, Sep 21 2012 *)

Extensions

More terms from David Wasserman, Feb 28 2006

A091267 Lengths of runs of 3's in A039702.

Original entry on oeis.org

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

Views

Author

Enoch Haga, Feb 22 2004

Keywords

Comments

Number of primes congruent to 3 mod 4 in sequence before interruption by a prime 1 mod 4.

Examples

			a(16)=4 because this is the sequence of primes congruent to 3 mod 4: 199, 211, 223, 227. The next prime is 229, a prime 1 mod 4.
		

References

  • Enoch Haga, Exploring prime numbers on your PC and the Internet with directions to prime number sites on the Internet, 2001, pages 30-31. ISBN 1-885794-17-7.

Crossrefs

Programs

  • Mathematica
    t = Length /@ Split[Table[Mod[Prime[n], 4], {n, 2, 400}]]; Most[Transpose[Partition[t, 2]][[1]]] (* T. D. Noe, Sep 21 2012 *)

Formula

Count primes congruent to 3 mod 4 in sequence before interruption by a prime divided by 4 with remainder 1.

A379403 Rectangular array, read by descending antidiagonals: the Type 1 runlength index array of A039702 (primes mod 4); see Comments.

Original entry on oeis.org

1, 2, 5, 3, 7, 20, 4, 9, 26, 23, 6, 13, 39, 71, 48, 8, 15, 60, 93, 80, 49, 10, 25, 76, 137, 94, 89, 96, 11, 28, 79, 156, 140, 95, 204, 133, 12, 30, 92, 187, 157, 199, 241, 356, 242, 14, 32, 113, 230, 198, 236, 271, 512, 457, 243, 16, 45, 118, 260, 233, 268
Offset: 1

Views

Author

Clark Kimberling, Jan 15 2025

Keywords

Comments

We begin with a definition of Type 1 runlength array, U(s), of a sequence s:
Suppose s is a sequence (finite or infinite), and define rows of U(s) as follows:
(row 0) = s
(row 1) = sequence of 1st terms of runs in (row 0); c(1) = complement of (row 1) in (row 0)
For n>=2,
(row n) = sequence of 1st terms of runs in c(n-1); c(n) = complement of (row n) in (row n-1),
where the process stops if and when c(n) is empty for some n.
***
The corresponding Type 1 runlength index array, UI(s) is now contructed from U(s) in two steps:
(1) Let U*(s) be the array obtaining by repeating the construction of U(s) using (n,s(n)) in place of s(n).
(2) Then UI(s) results by retaining only n in U*.
Thus, loosely speaking, (row n) of UI(s) shows the indices in s of the numbers in (row n) of U(s).
The array UI(s) includes every positive integer exactly once.
***
Regarding the present array, each row of U(s) splits an increasing sequence of primes according to remainder modulo 3; e.g., in row 2, the remainders of primes in positions 10,12,16,19,24,37 are 2,1,2,1,2,1,2,1, respectively.

Examples

			Corner:
    1    2     3     4     6     8    10    11    12    14    16    17
    5    7     9    13    15    25    28    30    32    45    47    51
   20   26    39    60    76    79    92   113   118   123   132   136
   23   71    93   137   156   187   230   260   283   296   318   326
   48   80    94   140   157   198   233   265   286   343   377   382
   49   89    95   199   236   268   472   595   635   702   732   755
   96  204   241   271   473   600   642   841   899   956  1120  1279
  133  356   512   601   643   844   906   961  1129  1402  1440  1482
  242  457   549   869   921   962  1220  1403  1567  1910  1946  2097
  243  460   566   870  1223  1406  1570  1917  1947  2102  2336  2655
  248  991  1242  1483  1745  2103  2367  2664  2981  3322  3440  3953
  249  992  1247  1484  1750  2118  2368  2667  3042  3323  3455  3956
Starting with s = A039702, we have for U*(s):
(row 1) = ((1,2), (2,3), (3,1), (4,3), (6,1), (8,3), (10,1), (11,3), ...)
c(1) = ((5,3), (7,1), (9,3), (13,1), (15,3), (20,3), (23,3), (25,1), (26,1), ...)
(row 2) = ((5,3), (7,1), (9,3), (13,1), (15,3), (25,1), (28,3), (30,1), (32,3), ...)
c(2) = ((20,3), (23,3), (26,1), ...)
(row 3) = ((20,3), (26,1), ...)
so that UI(s) has
(row 1) = (1,2,3,4,5,6,8,10,11, ...)
(row 2) = (5,7,9,13,15,25, ...)
(row 3) = (20,26,...)
		

Crossrefs

Programs

  • Mathematica
    r[seq_] := seq[[Flatten[Position[Prepend[Differences[seq[[All, 1]]], 1], _?(# != 0 &)]], 2]];
    row[0] = Mod[Prime[Range[4000]], 4];(* A039702 *)
    row[0] = Transpose[{#, Range[Length[#]]}] &[row[0]];
    k = 0; Quiet[While[Head[row[k]] === List, row[k + 1] = row[0][[r[SortBy[Apply[Complement,
            Map[row[#] &, Range[0, k]]], #[[2]] &]]]]; k++]];
    m = Map[Map[#[[2]] &, row[#]] &, Range[k - 1]];
    p[n_] := Take[m[[n]], 12]
    t = Table[p[n], {n, 1, 12}]
    Grid[t]
    w[n_, k_] := t[[n]][[k]];
    Table[w[n - k + 1, k], {n, 12}, {k, n, 1, -1}] // Flatten
    (* Peter J. C. Moses, Dec 04 2024 *)

A379404 Rectangular array, by descending antidiagonals: the Type 2 runlength index array of A039702 (primes mod 4); see Comments.

Original entry on oeis.org

1, 2, 4, 3, 6, 19, 5, 8, 24, 46, 7, 12, 47, 78, 31, 9, 22, 65, 128, 77, 14, 10, 25, 72, 135, 93, 50, 91, 11, 27, 87, 154, 134, 92, 168, 239, 13, 29, 94, 197, 153, 183, 240, 337, 232, 15, 38, 97, 247, 196, 241, 400, 540, 254, 229, 16, 44, 114, 264, 246, 435
Offset: 1

Views

Author

Clark Kimberling, Jan 15 2025

Keywords

Comments

We begin with a definition of Type 2 runlength array, V(s), of any sequence s for which all the runs referred to have finite length:
Suppose s is a sequence (finite or infinite), and define rows of V(s) as follows:
(row 0) = s
(row 1) = sequence of last terms of runs in (row 0); c(1) = complement of (row 1) in (row 0)
For n>=2,
(row n) = sequence of last terms of runs in c(n-1); c(n) = complement of (row n) in (row n-1),
where the process stops if and when c(n) is empty for some n.
***
The corresponding Type 2 runlength index array, The runlength index array, VI(s) is now contructed from V(s) in two steps:
(1) Let V*(s) be the array obtaining by repeating the construction of V(s) using (n,s(n)) in place of s(n).
(2) Then VI(s) results by retaining only n in V*.
Thus, loosely speaking, (row n) of VI(s) shows the indices in s of the numbers in (row n) of V(s).
The array VI(s) includes every positive integer exactly once.
***
Regarding the present array, each row of U(s) splits a sequence of primes according to remainder modulo 3; e.g., in row 2, the remainders of primes in positions 4,6,8,12,22,25,27,29 are 3,1,3,1,3,1,3,1, respectively.
Conjecture: every column is eventually increasing.

Examples

			Corner:
    1     2      3      5      7      9    10      11     13     15     16     17
    4     6      8     12     22     25    27      29     38     44     48     59
   19    24     47     65     72     87    94      97    114    121    131    136
   46    78    128    135    154    197   247     264    281    287    303    319
   31    77     93    134    153    196   246     263    280    338    363    378
   14    50     92    183    241    435   546     574    675    691    724    744
   91   168    240    400    543    571   758     834    887   1041   1240   1261
  239   337    540    568    707    833   886    1002   1381   1397   1407   1501
  232   254    674    824    885    987   1380   1500   1811   1883   1976   2280
  229   251    669    986   1377   1481   1802   1882   1971   2271   2444   2911
  626   983   1376   1480   1944   2240   2439   2910   3179   3295   3710   3939
  619   982   1333   1469   1943   2239   2366   2909   3178   3294   3701   3892
Starting with s = A039702, we have for U*(s):
(row 1) = ((1,2), (2,3), (3,1), (4,3), (5,3), (7,1), (9,3), (10,1), ...)
c(1) = ((4,3), (6,1), (8,3), (12,1), (14,3), (19,3), (22,3), (24,1), (25,1), ...)
(row 2) = ((4,3), (6,1), (8,3), (12,1), (22,3), (25,1), (27,3), (29,1) ...)
c(2) = ((14,3), (19,3), (24,1), ...)
(row 3) = ((19,3), (24,1), ...)
so that UI(s) has
(row 1) = (1,2,3,5,7,9,10,11,13, ...)
(row 2) = (4,6,8,12,22,25, ...)
(row 3) = (19,24,47, ...)
		

Crossrefs

Programs

  • Mathematica
    r[seq_] := seq[[Flatten[Position[Append[Differences[seq[[All, 1]]], 1], _?(# != 0 &)]], 2]];  (* Type 2 *)
    row[0] = Mod[Prime[Range[4000]], 4];(* A039701 *)
    row[0] = Transpose[{#, Range[Length[#]]}] &[row[0]];
    k = 0; Quiet[While[Head[row[k]] === List, row[k + 1] = row[0][[r[
         SortBy[Apply[Complement, Map[row[#] &, Range[0, k]]], #[[2]] &]]]]; k++]];
    m = Map[Map[#[[2]] &, row[#]] &, Range[k - 1]];
    p[n_] := Take[m[[n]], 12]
    t = Table[p[n], {n, 1, 12}]
    Grid[t]  (* array *)
    w[n_, k_] := t[[n]][[k]];
    Table[w[n - k + 1, k], {n, 12}, {k, n, 1, -1}] // Flatten  (* sequence *)
    (* Peter J. C. Moses, Dec 04 2024 *)

A039701 a(n) = n-th prime modulo 3.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

If n > 2 and prime(n) is a Mersenne prime then a(n) = 1. Proof: prime(n) = 2^p - 1 for some odd prime p, so prime(n) = 2*4^((p-1)/2) - 1 == 2 - 1 = 1 (mod 3). - Santi Spadaro, May 03 2002; corrected and simplified by Dean Hickerson, Apr 20 2003
Except for n = 2, a(n) is the smallest number k > 0 such that 3 divides prime(n)^k - 1. - T. D. Noe, Apr 17 2003
a(n) <> 0 for n <> 2; a(A049084(A003627(n))) = 2; a(A049084(A002476(n))) = 1; A134323(n) = (1 - 0^a(n)) * (-1)^(a(n)+1). - Reinhard Zumkeller, Oct 21 2007
Probability of finding 1 (or 2) in this sequence is 1/2. This follows from the Prime Number Theorem in arithmetic progressions. Examples: There are 4995 1's in terms (10^9 +1) to (10^9+10^4); there are 10^9/2-1926 1's in the first 10^9 terms. - Jerzy R Borysowicz, Mar 06 2022

Crossrefs

Cf. A091178 (indices of 1's), A091177 (indices of 2's).
Cf. A120326 (partial sums).
Cf. A010872.

Programs

Formula

Sum_k={1..n} a(k) ~ (3/2)*n. - Amiram Eldar, Dec 11 2024

A065338 a(1) = 1, a(p) = p mod 4 for p prime and a(u * v) = a(u) * a(v) for u, v > 0.

Original entry on oeis.org

1, 2, 3, 4, 1, 6, 3, 8, 9, 2, 3, 12, 1, 6, 3, 16, 1, 18, 3, 4, 9, 6, 3, 24, 1, 2, 27, 12, 1, 6, 3, 32, 9, 2, 3, 36, 1, 6, 3, 8, 1, 18, 3, 12, 9, 6, 3, 48, 9, 2, 3, 4, 1, 54, 3, 24, 9, 2, 3, 12, 1, 6, 27, 64, 1, 18, 3, 4, 9, 6, 3, 72, 1, 2, 3, 12, 9, 6, 3, 16, 81, 2, 3, 36, 1, 6, 3, 24, 1, 18, 3
Offset: 1

Views

Author

Reinhard Zumkeller, Oct 29 2001

Keywords

Examples

			a(120) = a(2*2*2*3*5) = a(2)*a(2)*a(2)*a(3)*a(5) = 2*2*2*3*1 = 24.
a(150) = a(2*3*5*5) = a(2)*a(3)*a(5)*a(5) = 2*3*1*1 = 6.
a(210) = a(2*3*5*7) = a(2)*a(3)*a(5)*a(7) = 2*3*1*3 = 18.
		

Crossrefs

Programs

  • Haskell
    a065338 1 = 1
    a065338 n = (spf `mod` 4) * a065338 (n `div` spf) where spf = a020639 n
    -- Reinhard Zumkeller, Nov 18 2011
    
  • Mathematica
    a[1] = 1; a[n_] := a[n] = Mod[p = FactorInteger[n][[1, 1]], 4]*a[n/p]; Table[ a[n], {n, 1, 100} ] (* Jean-François Alcover, Jan 20 2012 *)
  • PARI
    a(n)=my(f=factor(n)); prod(i=1,#f~, (f[i,1]%4)^f[i,2]) \\ Charles R Greathouse IV, Feb 07 2017

Formula

a(n) = 1 if n = 1, otherwise (A020639(n) mod 4) * n / A020639(n).
a(n) = (2^A007814(n)) * (3^A065339(n)).
a(n) <= n.
a(a(n)) = a(n).
a(x) = x iff x = 2^i * 3^j for i, j >= 0.
a(A003586(n)) = A003586(n).
a(A065331(n)) = A065331(n).
a(A004613(n)) = 1; A065333(a(n)) = 1. - Reinhard Zumkeller, Jul 10 2010
Dirichlet g.f.: (1/(1-2^(-s+1))) * Product_{prime p=4k+1} (1/(1-p^(-s))) * Product_{prime p=4k+3} 1/(1-3*p^(-s)). - Ralf Stephan, Mar 28 2015

A070750 0 if n-th prime is even, 1 if n-th prime is == 1 (mod 4), and -1 if n-th prime is == 3 (mod 4).

Original entry on oeis.org

0, -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: 1

Views

Author

Reinhard Zumkeller, May 04 2002

Keywords

Comments

Also, sin(prime(n)*Pi/2), where prime(n) = A000040(n), Pi=3.1415... (original definition).
Also imaginary part of primes mapped as defined in A076340, A076341: a(n) = A076341(A000040(n)), real part = A076342.
Legendre symbol (-1/prime(n)) for n > 1. - T. D. Noe, Nov 05 2003
For n > 1, let p = prime(n) and m = (p-1)/2. Then c(m) - a(n) == 0 (mod p), where c(m) = (2*m)!/(m!)^2 = A000984(m) is the central binomial coefficient. [Proof: By definition, c(m)*(m!)^2 - (p-1)! = 0 and therefore c(m)*(m!)^2*(-1)^(m+1) - (p-1)!*(-1)^(m+1) = 0. Now apply Wilson's theorem, (p-1)! == 1 (mod p), and its corollary, (m!)^2 == (-1)^(m+1) (mod p), and finally use the formula by T. D. Noe listed below to replace (-1)^m with a(n).] Similarly, C_m - 2*a(n) == 0 (mod p), with C_m = A000108(m) being the m-th Catalan number. [Proof: By definition, C_m*(p+1)*(m!)^2 - 2*(p-1)! = 0. The result follows proceeding as in the first proof.] - Stanislav Sykora, Aug 11 2014

Examples

			p = 4*k+1 (see A002144): a(p) = sin((4*k+1)*Pi/2) = sin(2*k*Pi + Pi/2) = sin(Pi/2) = 1.
p = 4*k+3 (see A002145): a(p) = sin((4*k+3)*Pi/2) = sin(2*k*Pi + 3*Pi/2) = sin(3*Pi/2) = -1.
		

Crossrefs

Programs

Formula

a(n) = 2 - prime(n) mod 4 = 2 - A039702(n).
a(n) = (-1)^((prime(n)-1)/2) for n > 1. - T. D. Noe, Nov 05 2003
From Amiram Eldar, Dec 24 2022: (Start)
Product_{n>=1} (1 - a(n)/prime(n)) = 4/Pi (A088538).
Product_{n>=1} (1 + a(n)/prime(n)) = 2/Pi (A060294). (End)

Extensions

Wording of definition changed by N. J. A. Sloane, Jun 21 2015

A039703 a(n) = n-th prime modulo 5.

Original entry on oeis.org

2, 3, 0, 2, 1, 3, 2, 4, 3, 4, 1, 2, 1, 3, 2, 3, 4, 1, 2, 1, 3, 4, 3, 4, 2, 1, 3, 2, 4, 3, 2, 1, 2, 4, 4, 1, 2, 3, 2, 3, 4, 1, 1, 3, 2, 4, 1, 3, 2, 4, 3, 4, 1, 1, 2, 3, 4, 1, 2, 1, 3, 3, 2, 1, 3, 2, 1, 2, 2, 4, 3, 4, 2, 3, 4, 3, 4, 2, 1, 4, 4, 1, 1, 3, 4, 3, 4, 2, 1, 3, 2, 4, 2, 1, 4, 3, 4, 1, 3, 1, 2, 2, 3, 4, 1
Offset: 1

Views

Author

Keywords

Comments

a(A049084(A045356(n-1))) = even; a(A049084(A045429(n-1))) = odd. - Reinhard Zumkeller, Feb 25 2008

Crossrefs

Programs

Formula

Sum_k={1..n} a(k) ~ (5/2)*n. - Amiram Eldar, Dec 11 2024

A242119 Primes modulo 18.

Original entry on oeis.org

2, 3, 5, 7, 11, 13, 17, 1, 5, 11, 13, 1, 5, 7, 11, 17, 5, 7, 13, 17, 1, 7, 11, 17, 7, 11, 13, 17, 1, 5, 1, 5, 11, 13, 5, 7, 13, 1, 5, 11, 17, 1, 11, 13, 17, 1, 13, 7, 11, 13, 17, 5, 7, 17, 5, 11, 17, 1, 7, 11, 13, 5, 1, 5, 7, 11, 7, 13, 5, 7, 11, 17, 7, 13, 1, 5
Offset: 1

Views

Author

Vincenzo Librandi, May 05 2014

Keywords

Crossrefs

Cf. sequences of the type Primes mod k: A039701 (k=3), A039702 (k=4), A039703 (k=5), A039704 (k=6), A039705 (k=7), A039706 (k=8), A038194 (k=9), A007652 (k=10), A039709 (k=11), A039710 (k=12), A039711 (k=13), A039712 (k=14), A039713 (k=15), A039714 (k=16), A039715 (k=17), this sequence (k=18), A033633 (k=19), A242120(k=20), A242121 (k=21), A242122 (k=22), A229786 (k=23), A229787 (k=24), A242123 (k=25), A242124 (k=26), A242125 (k=27), A242126 (k=28), A242127 (k=29), A095959 (k=30), A110923 (k=100).

Programs

  • Magma
    [p mod(18): p in PrimesUpTo(500)];
    
  • Mathematica
    Mod[Prime[Range[100]], 18]
  • Sage
    [mod(p, 18) for p in primes(500)] # Bruno Berselli, May 05 2014

Formula

Sum_{i=1..n} a(i) ~ 9n. The derivation is the same as in the formula in A039715. - Jerzy R Borysowicz, Apr 27 2022
Showing 1-10 of 27 results. Next