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-3 of 3 results.

A159559 Lexicographically first strictly increasing sequence starting a(2) = 3 with the property that a(n) is prime if and only if n is prime.

Original entry on oeis.org

3, 5, 6, 7, 8, 11, 12, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 29, 30, 32, 33, 37, 38, 39, 40, 42, 44, 47, 48, 53, 54, 55, 56, 57, 58, 59, 60, 62, 63, 67, 68, 71, 72, 74, 75, 79, 80, 81, 82, 84, 85, 89, 90, 91, 92, 93, 94, 97, 98, 101, 102, 104, 105, 106, 108, 109, 110, 111
Offset: 2

Views

Author

Vladimir Shevelev, Apr 15 2009, May 04 2009

Keywords

Comments

a(n) is prime iff n is prime.

Examples

			For n = 6, since n is composite, a(6) is the smallest composite number greater than a(6-1) = a(5) = 7, so a(6) = 8. For n = 11, since n is prime, a(11) is the smallest prime number greater than a(11-1) = a(10) = 15, so a(12) = 17. - _Michael B. Porter_, Sep 04 2016
		

Crossrefs

Programs

  • Maple
    A159559 := proc(n) option remember; if n = 2 then 3; else for a from procname(n-1)+1 do if isprime(n) and isprime(a) then RETURN(a) ; elif not isprime(n) and not isprime(a) then RETURN(a) ; fi; od: fi; end: seq(A159559(n),n=2..100) ; # R. J. Mathar, Jul 28 2009
  • Mathematica
    a[2] = 3;
    a[n_] := a[n] = If[PrimeQ[n], NextPrime[a[n-1]], NestWhile[#+1&, a[n-1]+1, PrimeQ]];
    Map[a, Range[2, 100]] (* Peter J. C. Moses, Sep 19 2013 *)
  • PARI
    nextcomposite(n)=if(n<4, return(4)); n=ceil(n); if(isprime(n),n+1,n)
    first(n)=my(v=vector(n)); v[2]=3; for(k=3,n, v[k]=if(isprime(k),nextprime(v[k-1]+1), nextcomposite(v[k-1]+1))); v[2..n] \\ Charles R Greathouse IV, Sep 21 2016

Formula

a(n+1) = min{m>a(n), m is prime}, if n+1 is prime; otherwise, a(n+1) = min{m>a(n), m is composite}.

Extensions

More terms from R. J. Mathar, Jul 28 2009

A159698 Minimal increasing sequence beginning with 4 such that n and a(n) are either both prime or both nonprime.

Original entry on oeis.org

4, 5, 7, 8, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 29, 30, 32, 33, 37, 38, 39, 40, 42, 44, 47, 48, 53, 54, 55, 56, 57, 58, 59, 60, 62, 63, 67, 68, 71, 72, 74, 75, 79, 80, 81, 82, 84, 85, 89, 90, 91, 92, 93, 94, 97, 98, 101, 102, 104, 105, 106, 108, 109, 110, 111, 112
Offset: 1

Views

Author

Vladimir Shevelev, Apr 20 2009, May 04 2009

Keywords

Comments

For n >= 11, a(n) = A159559(n), which means the two sequences merge.
We may define other sequences a(p-1,n), p prime, which start a(p-1,1)=p-1 and with the same property of n and a(p-1,n) being jointly prime or nonprime.
We find that for p=7, 11 and 13, the sequences a(6,n), a(10,n) and a(12,n) also merge with the current sequence for sufficiently large n. Does this also hold for primes >=17?
It was verified for primes p with 7<=p<=223 that this sequence a(4,n) and a(p-1,n) eventually merge. The corresponding values of n are 47, 683, 1117, 6257, 390703. - Alois P. Heinz, Mar 09 2011

Crossrefs

Programs

  • Maple
    a:= proc(n) option remember; local m;
          if n=1 then 4
        else for m from a(n-1)+1 while isprime(m) xor isprime(n)
             do od; m
          fi
        end:
    seq(a(n), n=1..80);  # Alois P. Heinz, Nov 21 2010
  • Mathematica
    a[n_] := a[n] = If[n==1, 4, For[m = a[n-1]+1, Xor[PrimeQ[m], PrimeQ[n]], m++]; m]; Table[a[n], {n, 1, 80}] (* Jean-François Alcover, Jan 31 2016, after Alois P. Heinz *)

Formula

a(1) = 4; for n>1, a(n) = min { m > a(n-1) : m is prime iff n is prime }.

Extensions

More terms from Alois P. Heinz, Nov 21 2010

A276676 Triangle read by rows: T(n,k) (n>=2, k=2,...,n) is the minimal position at which the sequence A_n merges with the sequence A_k, where A_n be the sequence defined in the same way as A159559 but with initial term prime(n).

Original entry on oeis.org

2, 11, 2, 47, 47, 2, 47, 47, 11, 2, 47, 47, 17, 17, 2, 683, 683, 683, 683, 683, 2, 683, 683, 683, 683, 683, 11, 2, 683, 683, 683, 683, 683, 17, 17, 2, 683, 683, 683, 683, 683, 467, 467, 467, 2, 683, 683, 683, 683, 683, 467, 467, 467, 11, 2, 683, 683, 683, 683, 683, 467, 467, 467, 79, 79, 2
Offset: 2

Views

Author

Vladimir Shevelev, Sep 13 2016

Keywords

Examples

			Triangle begins
2;
11,2;
47,47,2;
47,47,11,2;
47,47,17,17,2;
683,683,683,683,683,2;
683,683,683,683,683,11,2;
683,683,683,683,683,17,17,2;
683,683,683,683,683,467,467,467,2;
683,683,683,683,683,467,467,467,11,2;
683,683,683,683,683,467,467,467,79,79,2;
683,683,683,683,683,467,467,467,79,79,17,2;
683,683,683,683,683,467,467,467,79,79,41,41,2;
683,683,683,683,683,467,467,467,79,79,41,41,11,2;
683,683,683,683,683,467,467,467,79,79,41,41,17,17,2;
683,683,683,683,683,467,467,467,107,107,107,107,107,107,107,2;
683,683,683,683,683,467,467,467,107,107,107,107,107,107,107,11,2;
The first column forms A229019.
		

Crossrefs

Cf. A159559, A229019 (the first column), A229132.

Programs

  • Mathematica
    f[n_, r_] := Block[{a}, a[2] = n; a[x_] := a[x] = If[PrimeQ@ x, NextPrime@ a[x - 1], NestWhile[# + 1 &, a[x - 1] + 1, PrimeQ@ # &]]; Map[a, Range[2, r]]]; nn = 10^4; Table[1 + First@ Flatten@ Position[BitXor[f[Prime@ n, nn], f[Prime@ k, nn]], 0], {n, 2, 12}, {k, 2, n}] // Flatten (* Michael De Vlieger, Sep 13 2016, after Peter J. C. Moses at A159559 *)

Extensions

More terms from Peter J. C. Moses, Sep 13 2016
Showing 1-3 of 3 results.