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.

A121562 Lengths of runs of identical terms in A121561.

Original entry on oeis.org

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

Views

Author

Kerry Mitchell, Aug 07 2006

Keywords

Examples

			a(2) = 7 because A121561 begins 0, 1, 1, 1, 1, 1, 1, 1 and the second block of identical terms is 7 ones.
		

Crossrefs

Cf. A121561.

Extensions

Name and example edited by M. F. Hasler, Jan 07 2019

A138026 Numbers k where A121561(k) = 3.

Original entry on oeis.org

122, 123, 148, 190, 208, 209, 220, 221, 250, 292, 302, 303, 326, 327, 346, 418, 430, 476, 477, 518, 519, 532, 533, 538, 539, 556, 586, 628, 629, 640, 670, 671, 700, 718, 782, 783, 796, 806, 807, 820, 838, 848, 849, 872, 873, 896, 897, 902, 903, 928, 962
Offset: 1

Views

Author

Robert G. Wilson v, Feb 27 2008

Keywords

Crossrefs

Programs

  • Maple
    filter:= proc(n)
      local t;
      t:= n-prevprime(n+1);
      if t <= 1 then return false fi;
      t:= t-prevprime(t+1);
      if t <= 1 then return false fi;
      isprime(t) or isprime(t-1)
    end proc:
    select(filter,[$2..1000]); # Robert Israel, Jan 15 2019
  • Mathematica
    LrgstPrm[n_] := Block[{k = n}, While[ !PrimeQ@k, k-- ]; k]; f[n_] := Block[{c = 0, d = n}, While[d > 1, d = d - LrgstPrm@ d; c++ ]; c]; lst = {}; Do[ If[f@n == 3, AppendTo[lst,n]], {n, 10^3}]; lst

A138027 Numbers k where A121561(k) = 4.

Original entry on oeis.org

1357323, 1357324, 1562041, 1562042, 1671903, 1671904, 1889953, 1889954, 2010855, 2010856, 3826141, 3826142, 3851581, 3851582, 3933721, 3933722, 4652475, 4652476, 4652501, 4738773, 4738774, 5518809, 5518810, 5826123
Offset: 1

Views

Author

Robert G. Wilson v, Feb 27 2008, Mar 06 2008

Keywords

Crossrefs

Programs

  • Mathematica
    LrgstPrm[n_] := Block[{k = n}, While[ !PrimeQ@k, k-- ]; k]; f[n_] := Block[{c = 0, d = n}, While[d > 1, d = d - LrgstPrm@ d; c++ ]; c]; lst = {}; Do[ If[f@n == 4, AppendTo[lst,n]], {n, 2*10^6}]; lst

A135543 Record number of steps under iterations of "map n to n - (largest prime <= n)" (A064722) until reaching the limiting value 0 or 1. Also, places where A121561 reaches a new record.

Original entry on oeis.org

1, 2, 9, 122, 1357323
Offset: 0

Views

Author

Sergio Pimentel, Feb 22 2008

Keywords

Comments

a(5) must be very large (> 100000000). Can anyone extend the sequence?
Conjecture: there exist positive values of n for which a(n) != A175079(n) - 1. - Jaroslav Krizek, Feb 05 2010
From Thomas R. Nicely's data (see link) it seems that the smallest known prime with following prime gap of length a(4)+1 or more is 90823#/510510 - 1065962 (39279 digits), so a(5) = A104138(a(4)) + a(4) <= 90823#/510510 - 1065962 + 1357323 = A002110(8787)/510510 + 291361. (The bounding primes of this prime gap are only known to be probable primes, but if either of them were not prime, the gap would only be larger and the bound on a(5) would still hold.) - Pontus von Brömssen, Jul 31 2022

Examples

			a(4) = 1357323 because after iterating n - (largest prime <= n) we get:
  1357323 - 1357201 = 122 =>
  122 - 113 = 9 =>
  9 - 7 = 2 =>
  2 - 2 = 0,
which takes 4 steps.
		

Crossrefs

Programs

  • Mathematica
    LrgstPrm[n_] := Block[{k = n}, While[ !PrimeQ@ k, k-- ]; k]; f[n_] := Block[{c = 0, d = n}, While[d > 1, d = d - LrgstPrm@d; c++ ]; c]; lst = {}; record = -1; Do[ a = f@n; If[a > record, record = a; AppendTo[lst, a]; Print@ n], {n, 100}] (* Robert G. Wilson v *)
  • Python
    from sympy import prevprime
    from functools import lru_cache
    from itertools import count, islice
    @lru_cache(maxsize=None)
    def f(n): return 0 if n == 0 or n == 1 else 1 + f(n - prevprime(n+1))
    def agen(record=-1):
        for k in count(1):
            if f(k) > record: record = f(k); yield k
    print(list(islice(agen(), 4))) # Michael S. Branicky, Jul 26 2022

Formula

Iterate n - (largest prime <= n) until reaching 0 or 1. Count the iterations required to reach 0 or 1 and determine if it is a new record.
From Pontus von Brömssen, Jul 31 2022: (Start)
a(n) = A104138(a(n-1)) + a(n-1) for n >= 2.
A121561(a(n)) = n.
a(n) = A175079(n) - 1 for n >= 1, i.e., the conjecture in the Comments is false. This follows from the result that A175078(n) = A121561(n-1) for n >= 2.
(End)

A093515 Numbers k such that either k or k-1 is a prime.

Original entry on oeis.org

2, 3, 4, 5, 6, 7, 8, 11, 12, 13, 14, 17, 18, 19, 20, 23, 24, 29, 30, 31, 32, 37, 38, 41, 42, 43, 44, 47, 48, 53, 54, 59, 60, 61, 62, 67, 68, 71, 72, 73, 74, 79, 80, 83, 84, 89, 90, 97, 98, 101, 102, 103, 104, 107, 108, 109, 110, 113, 114, 127, 128, 131, 132, 137, 138, 139
Offset: 1

Views

Author

Ferenc Adorjan (fadorjan(AT)freemail.hu)

Keywords

Comments

Original name: Transform of the prime sequence by the Rule 110 cellular automaton.
As described in A051006, a monotonic sequence can be mapped into a fractional real. Then the binary digits of that real can be treated (transformed) by an elementary cellular automaton. Taking the resulting sequence of binary digits as a fractional real, it can be mapped back into a sequence, as in A092855.
From M. F. Hasler, Mar 01 2008: (Start)
The "Rule110" transform as used here involves a right-shift of the sequence before applying the transform as described on the MathWorld page.
Robert G. Wilson v observed that this sequence contains exactly the indices for which A121561 equals 1. (End)
From M. F. Hasler, Jan 07 2019: (Start)
The correspondence of monotonic sequences with fractional reals mentioned in the first comment is not really relevant here: RuleX most naturally maps directly one characteristic sequence to another and thus one set (or increasing sequence) to another one. Interpreting the characteristic sequences as binary digits of a fractional real then yields a map from [0,1] into [0,1] rather as a consequence.
Antti Karttunen observed that this seems to be the complement of A005381 (k and k-1 are composite). This is indeed the case: The characteristic sequence of primes has no three subsequent 1's. In all other cases of the 8 possible inputs for Rule110, the output is 0 if and only if the cell itself and its neighbor to the right are zero, which here means "k and k+1 are composite", and with the right shift mentioned above, the complement of A005381, i.e., numbers such that k or k-1 is prime (or: primes U primes + 1). We have actually proved the more general
Theorem: Rule110 transforms any set S having no three consecutive integers into the set S' = {k | k or k-1 is in S} = S U (1 + S). (End)

Crossrefs

Cf. A005381 (complement, apart from 1 which is in neither sequence), A323162.
Cf. A121561.

Programs

  • Magma
    [n: n in [2..180] | not(not IsPrime(n) and not IsPrime(n-1))]; // Vincenzo Librandi, Jan 08 2019
    
  • Mathematica
    Select[Range[2, 150], !(!PrimeQ[# - 1] && !PrimeQ[#]) &] (* Vincenzo Librandi, Jan 08 2019 *)
  • PARI
    {ca_tr(ca,v)= /* Calculates the Cellular Automaton transform of the vector v by the rule ca */
    local(cav=vector(8),a,r=[],i,j,k,l,po,p=vector(3));
    a=binary(min(255,ca));k=matsize(a)[2];forstep(i=k,1,- 1,cav[k-i+1]=a[i]);
    j=0;l=matsize(v)[2];k=v[l];po=1;
    for(i=1,k+2,j*=2;po=isin(i,v,l,po);j=(j+max(0,sign(po)))% 8;if(cav[j+1],r=concat(r,i)));
    return(r) /* See the function "isin" at A092875 */}
    
  • PARI
    /* transform a sequence v by the rule r - Note: v could be replaced by a function, e.g. v[c] => prime(c) here */
    seqruletrans(v,r)={my(c=1,L=List(),t=0); r=Vecrev(binary(r),8); for(i=1,v[#v], v[c]A093515=seqruletrans(primes(10^4),110) \\ M. F. Hasler, Mar 01 2008, updated Jan 07 2019
    
  • PARI
    A121561_is_1(N,n=0)=vector(N,i, while(!isprime(n+=1)&&!isprime(n-1),);n) \\ M. F. Hasler, Mar 01 2008
    
  • PARI
    is(n)=isprime(n)||isprime(n-1) \\ M. F. Hasler, Jan 07 2019
    
  • Python
    from sympy import isprime
    def ok(n): return isprime(n) or isprime(n-1)
    print(list(filter(ok, range(140)))) # Michael S. Branicky, Aug 10 2021

Formula

{a(n)} = A000040 U (A000040 + 1), where A000040 are the primes. - M. F. Hasler, Jan 07 2019
a(1) = 2, a(n) = a(n-1) + 1 if a(n-1) is prime, a(n) is the next prime after a(n-1) otherwise. - Luca Armstrong, Aug 10 2021

Extensions

Name changed by Antti Karttunen, Jan 07 2019

A121559 Final result (0 or 1) under iterations of {r mod (max prime p <= r)} starting at r = n.

Original entry on oeis.org

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

Author

Kerry Mitchell, Aug 07 2006

Keywords

Comments

Previous name: Find r1 = n modulo p1, where p1 is the largest prime not greater than n. Then find r2 = r1 modulo p2, where p2 is the largest prime not greater than r1. Repeat until the last r is either 1 or 0; a(n) is the last r value.
The sequence has the form of blocks of 0's between 1's. See sequence A121560 for the lengths of the blocks of zeros.
The function r mod (max prime p <= r), which appears in the definition, equals r - (max prime p <= r) = A064722(r), because p <= r < 2*p by Bertrand's postulate, where p is the largest prime less than or equal to r. - Pontus von Brömssen, Jul 31 2022

Examples

			a(9) = 0 because 7 is the largest prime not larger than 9, 9 mod 7 = 2, 2 is the largest prime not greater than 2 and 2 mod 2 = 0.
		

Crossrefs

Cf. A007917 and A064722 (both for the iterations).

Programs

  • Mathematica
    Abs[Table[FixedPoint[Mod[#,NextPrime[#+1,-1]]&,n],{n,110}]] (* Harvey P. Dale, Mar 17 2023 *)
  • PARI
    a(n) = if (n==1, return (1)); na = n; while((nb = (na % precprime(na))) > 1, na = nb); return(nb); \\ Michel Marcus, Aug 22 2014

Formula

a(p) = 0 when p is prime. - Michel Marcus, Aug 22 2014
a(n) = A175077(n+1) - 1. - Pontus von Brömssen, Jul 31 2022
a(n) = A200947(n) mod 2. - Alois P. Heinz, Jun 12 2023

Extensions

New name from Michel Marcus, Aug 22 2014

A175078 Number of iterations of {r mod (max prime p < r)} needed to reach 1 or 2 starting at r = n.

Original entry on oeis.org

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

Author

Jaroslav Krizek, Jan 23 2010

Keywords

Comments

a(123) = 3 (first occurrence of value 3), a(1357324) = 4 (first occurrence of value 4). I offer a prize of 100 liters of Pilsner Urquell to the discoverer of value of first occurrence of value 5. See A175071 (natural numbers m with result 1) and A175072 (natural numbers m with result 2). See A175077 = results 1 or 2 under iterations of {r mod (max prime p < r)} starting at r = n.
Essentially the same as A121561. [R. J. Mathar, Jan 28 2010]
The function r mod (max prime p < r), which appears in the definition, equals r - (max prime p < r) = A049711(r), because p < r < 2*p by Bertrand's postulate, where p is the largest prime less than r. - Pontus von Brömssen, Jul 31 2022

Examples

			a(123) = 3; iteration procedure for n = 123: 123 mod 113 = 10, 10 mod 7 = 3, 3 mod 2 = 1.
		

Programs

  • Mathematica
    Array[-1 + Length@ NestWhileList[Mod[#, NextPrime[#, -1]] &, #, Not[1 <= # <= 2] &, 1, 120] &, 105] (* Michael De Vlieger, Oct 30 2017 *)
  • PARI
    A175078(n) = if(n<=2,0,1+A175078(n%precprime(n-1))); \\ Antti Karttunen, Oct 30 2017

Formula

a(n) = A121561(n-1) for n >= 2, because the functions that are iterated (A049711 here, A064722 in A121561) satisfies A049711(r) = A064722(r-1) + 1. - Pontus von Brömssen, Jul 31 2022

Extensions

Name shortened by Antti Karttunen, Oct 30 2017

A175079 The smallest natural numbers m with first occurrence 0, 1, 2, 3, ... for number of steps of iterations of {r mod (max prime p < r)} needed to reach 1 or 2 starting at r = m.

Original entry on oeis.org

1, 3, 10, 123, 1357324
Offset: 0

Author

Jaroslav Krizek, Jan 23 2010

Keywords

Comments

I offer a prize of 100 liters of Pilsner Urquell to the discoverer of a(5). Conjecture: a(n) is not equal A135543(n) + 1 for all n >= 1. See A175071 (natural numbers m with result 1) and A175072 (natural numbers m with result 2). See A175077 (results 1 or 2 under iterations) and A175078 (number of steps of iterations).

Examples

			Iteration for a(4) = 1357324 has 4 steps: 1357324 mod 1357201 = 123, 123 mod 113 = 10, 10 mod 7 = 3, 3 mod 2 = 1.
		

Formula

From Pontus von Brömssen, Jul 31 2022: (Start)
a(n) = A135543(n) + 1 for n >= 1, i.e., the conjecture in the Comments is false. This follows from the result that A175078(n) = A121561(n-1) for n >= 2.
a(5) = A135543(5) + 1 <= A002110(8787)/510510 + 291362 (see comment in A135543).
(End)

Extensions

Jaroslav Krizek, Jan 30 2010
Showing 1-8 of 8 results.