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 10 results.

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

Views

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

A007924 The number n written using the greedy algorithm in the base where the values of the places are 1 and primes.

Original entry on oeis.org

0, 1, 10, 100, 101, 1000, 1001, 10000, 10001, 10010, 10100, 100000, 100001, 1000000, 1000001, 1000010, 1000100, 10000000, 10000001, 100000000, 100000001, 100000010, 100000100, 1000000000, 1000000001, 1000000010, 1000000100, 1000000101
Offset: 0

Views

Author

R. Muller

Keywords

Comments

Any nonnegative number can be written as a sum of distinct primes + e, where e is 0 or 1.
Terms contain only digits 0 and 1.
Without the "greedy" condition there is ambiguity - for example 5 = 3+2 has two representations.

Examples

			4 = 3 + 1, so a(4) = 101.
		

References

  • S. S. Pillai, "An arithmetical function concerning primes", Annamalai University Journal (1930), pp. 159-167.

Crossrefs

Subsequence of A007088.

Programs

  • Mathematica
    cprime[n_Integer] := (If[n==0, 1, Prime[n]]);gentable[n_Integer] := (m=n; ptable={};While[m!=0, (i=0; While[cprime[i]<=m, i++]; j=0;While[jFrank M Jackson, Jan 06 2012 *)
  • PARI
    a(n)=if(n>1, my(p=precprime(n)); 10^primepi(p)+a(n-p), n) \\ Charles R Greathouse IV, Feb 01 2013

Formula

a(n) is the binary representation of b(n) = 2^pi(n) + b(n-p(pi(n))) for n > 0 and a(0) = b(0)= 0, where pi(k) = number of primes <= k (A000720) and p(k) = k-th prime (A008578). - Frank Ellermann, Dec 18 2001

Extensions

Additional references from Felice Russo, Sep 14 2001
Antedated to 1930 by Charles R Greathouse IV, Aug 28 2010
Definition clarified by Frank M Jackson and N. J. A. Sloane, Dec 30 2011

A075058 Lexicographically earliest infinite sequence of distinct positive numbers with the property that every positive integer is a sum of distinct terms (see algorithm below).

Original entry on oeis.org

1, 2, 3, 7, 13, 23, 47, 97, 193, 383, 769, 1531, 3067, 6133, 12269, 24533, 49069, 98129, 196247, 392503, 785017, 1570007, 3140041, 6280067, 12560147, 25120289, 50240587, 100481167, 200962327, 401924639, 803849303, 1607698583, 3215397193, 6430794373
Offset: 0

Views

Author

Amarnath Murthy, Sep 07 2002

Keywords

Comments

This sequence starts with a(0)=1, subsequent terms a(n) for n > 0 being obtained by selecting the greatest prime <= 1 + Sum_{i=0..n-1} a(i). This ensures that the sequence has the required property because Sum_{i=0..n-1} a(i) >= a(n) - 1, for all n >= 0 and a(0)=1, is a necessary and sufficient condition for it to hold.

Examples

			Given that the first 7 terms of the sequence are 1,2,...,23,47 then a(8)=(greatest prime) <= (1+2+...+23,47) + 1 = 97, hence a(8)=97.
		

Crossrefs

Programs

  • Mathematica
    prevprime[n_Integer] := (j=n; While[!PrimeQ[j], j--]; j) aprime[0]=1; aprime[n_Integer] := (aprime[n] = prevprime[Sum[aprime[m], {m, 0, n - 1}] + 1]); Table[aprime[p], {p, 0, 50}]
    a[0] = 1; a[n_] := a[n] = NextPrime[Sum[a[k], {k, 0, n-1}]+2, -1]; Table[a[n], {n, 0, 33}] (* Jean-François Alcover, Sep 30 2013 *)
  • PARI
    print1(s=1);for(n=1,20,k=precprime(s+1);print1(", "k);s+=k) \\ Charles R Greathouse IV, Apr 05 2013

Formula

a(n) = (greatest prime) <= 1 + Sum_{i=0..n-1} a(i).
a(n) ~ k*2^n, with k roughly 0.748643. - Charles R Greathouse IV, Apr 05 2013

Extensions

Entry revised by Frank M Jackson, Dec 03 2011
Edited by N. J. A. Sloane, May 20 2023

A185101 The number n written using the minimum number of terms in the base where the values of the places are 1 and primes (noncomposites). For multiple solutions the smallest binary value is chosen.

Original entry on oeis.org

0, 1, 10, 100, 101, 1000, 1001, 10000, 1100, 10010, 10100, 100000, 11000, 1000000, 100100, 1000010, 101000, 10000000, 110000, 100000000, 1010000, 100000010, 10001000, 1000000000, 1100000, 1000000010, 100010000, 1100100, 10100000, 10000000000
Offset: 0

Views

Author

Frank M Jackson, Jan 23 2012

Keywords

Comments

There are many ways of generating binary vectors a(n) for selecting noncomposites that when summed give n. A007924 uses the greedy algorithm. The above sequence uses the strong Goldbach conjecture that any integer is the sum of at most three distinct summands. It generates a(n) to select the minimum number of distinct noncomposites. Where there are multiple solutions, it chooses the smallest binary vector.

Examples

			n=57 which is > 6 and odd, so m = (nextprime > 57/3) = 23 and n-m = 34 is even, thus A082467(17) = 6 and algorithm selects {23,11,23}. These are not distinct primes, so m = nextprime(nextprime > n/3) = 29 and A082467(14)=3, thus a(n) selects {29,11,17} as the binary vector 10010100000.
		

Crossrefs

Programs

  • Mathematica
    nextprime[j_] := Module[{k}, If[j==0, 1, (k=Floor[j]+1; While[!PrimeQ[k], k++]; k)]]; primetable[n_] := Module[{p, q}, Which[n==1, {0, 2, 0}, n==2, {1, 3, 0}, n==3, {1, 5, 0}, True, (p=n+1; q=2n-p; While[q>0&&!(PrimeQ[p]&&PrimeQ[q]), p++; q--]; {0, q, p})]]; fintable[m_] := Module[{temptable}, Which[m==0, {0, 0, 0}, m==1, {1, 0, 0}, PrimeQ[m], {0, m, 0}, PrimeQ[m-2]&&m>4, {0, 2, m-2}, EvenQ[m], primetable[m/2], True, (temptable=primetable[(m-nextprime[m/3])/2]; If[temptable[[3]]==nextprime[m/3], (temptable=primetable[(m-nextprime[nextprime[m/3]])/2]; temptable[[1]]=nextprime[nextprime[m/3]]), temptable[[1]]=nextprime[m/3]]; temptable)]]; decimal[t_] := Module[{temp2table, tempdecimal=0}, (temp2table=fintable[t]; If[temp2table[[1]]==0, Null, tempdecimal=tempdecimal+2^PrimePi[temp2table[[1]]]]; If[temp2table[[2]]==0, Null, tempdecimal=tempdecimal+2^PrimePi[temp2table[[2]]]]; If[temp2table[[3]]==0, Null, tempdecimal=tempdecimal+2^PrimePi[temp2table[[3]]]];tempdecimal)];Table[IntegerString[decimal[i], 2], {i, 0, 100}]

Formula

For n, 1 to 6, a(n) is manually defined. For n prime, a(n) selects n. For n > 6 and n-2 prime, a(n) selects 2 and n-2. For n > 6 and even, use A082467(n/2) to give k, then a(n) selects n/2+k, n/2-k. For n>6 and odd, let m = (nextprime > n/3), then n-m is even and A082467((n-m)/2) gives k, a(n) selects m, (n-m)/2-k, (n-m)/2+k. If m = (n-m)/2+k, then m = nextprime(nextprime > n/3) and repeat.

Extensions

Name clarified by Frank M Jackson, Oct 08 2013

A345297 a(n) is the least k >= 0 such that A331835(k) = n.

Original entry on oeis.org

0, 1, 2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 22, 23, 26, 27, 29, 30, 31, 43, 45, 46, 47, 54, 55, 58, 59, 61, 62, 63, 94, 95, 107, 109, 110, 111, 118, 119, 122, 123, 125, 126, 127, 187, 189, 190, 191, 222, 223, 235, 237, 238, 239, 246, 247, 250, 251, 253, 254, 255
Offset: 0

Views

Author

Rémy Sigrist, Jun 13 2021

Keywords

Comments

Sequence A200947 gives the position of the last occurrence of a number in A331835.

Examples

			We have:
           n|  0  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18
  ----------+------------------------------------------------------------------
  A331835(n)|  0  1  2  3  3  4  5  6  5  6   7   8   8   9  10  11   7   8   9
So a(0) = 0,
   a(1) = 1,
   a(2) = 2,
   a(3) = 3,
   a(4) = 5,
   a(5) = 6,
   a(6) = 7,
   a(7) = 10,
   a(8) = 11,
   a(9) = 13,
   a(10) = 14,
   a(11) = 15.
		

Crossrefs

Programs

  • C
    See Links section.
    
  • Python
    from sympy import prime
    def p(n): return prime(n) if n >= 1 else 1
    def A331835(n): return sum(p(i)*int(b) for i, b in enumerate(bin(n)[:1:-1]))
    def adict(klimit):
        adict = dict()
        for k in range(klimit+1):
            fk = A331835(k)
            if fk not in adict: adict[fk] = k
        n, alst = 0, []
        while n in adict: alst.append(adict[n]); n += 1
        return alst
    print(adict(255)) # Michael S. Branicky, Jun 13 2021

Formula

a(A014284(n)) = 2^n - 1.
a(n) <= A200947(n).

A331835 Replace 2^k in binary expansion of n with k-th prime number for any k > 0 (and keep 2^0).

Original entry on oeis.org

0, 1, 2, 3, 3, 4, 5, 6, 5, 6, 7, 8, 8, 9, 10, 11, 7, 8, 9, 10, 10, 11, 12, 13, 12, 13, 14, 15, 15, 16, 17, 18, 11, 12, 13, 14, 14, 15, 16, 17, 16, 17, 18, 19, 19, 20, 21, 22, 18, 19, 20, 21, 21, 22, 23, 24, 23, 24, 25, 26, 26, 27, 28, 29, 13, 14, 15, 16, 16
Offset: 0

Views

Author

Rémy Sigrist, Jan 28 2020

Keywords

Comments

Every nonnegative integer appears in this sequence as A008578 is a complete sequence.
For any m >= 0, m appears A036497(m) times, the first and last occurrences being at indices A345297(m) and A200947(m), respectively. - Rémy Sigrist, Jun 13 2021

Examples

			For n = 43:
- 43 = 2^0 + 2^1 + 2^3 + 2^5,
- so a(43) = 2^0 + prime(1) + prime(3) + prime(5) = 1 + 2 + 5 + 11 = 19.
		

Crossrefs

Programs

  • Mathematica
    Array[Total@ Map[If[# == 0, 1, Prime[#]] &, Position[Reverse@ IntegerDigits[#, 2], 1][[All, 1]] - 1] &, 68] (* Michael De Vlieger, Jan 29 2020 *)
  • PARI
    a(n) = my (b=Vecrev(binary(n\2))); n%2 + sum(k=1, #b, if (b[k], prime(k), 0))
    
  • Python
    from sympy import prime
    def p(n): return prime(n) if n >= 1 else 1
    def a(n): return sum(p(i)*int(b) for i, b in enumerate(bin(n)[:1:-1]))
    print([a(n) for n in range(69)]) # Michael S. Branicky, Jun 13 2021

Formula

a(2*n) = A089625(n) for any n > 0.
a(2*n+1) = A089625(n) + 1 for any n > 0.
G.f.: x/(1 - x^2) + (1/(1 - x)) * Sum_{k>=1} prime(k) * x^(2^k) / (1 + x^(2^k)). - Ilya Gutkovskiy, May 24 2024

A368577 Irregular table T(n, k), n >= 0, k = 1..A036497(n), read by rows; the n-th row lists the numbers m such that A331835(m) = n.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 8, 7, 9, 10, 16, 11, 12, 17, 13, 18, 14, 19, 20, 15, 21, 32, 22, 24, 33, 23, 25, 34, 64, 26, 35, 36, 65, 27, 28, 37, 66, 29, 38, 40, 67, 68, 30, 39, 41, 69, 128, 31, 42, 48, 70, 72, 129, 43, 44, 49, 71, 73, 130, 256, 45, 50, 74, 80, 131, 132, 257
Offset: 0

Views

Author

Rémy Sigrist, Dec 31 2023

Keywords

Comments

As a flat sequence, this is a permutation of the nonnegative integers (with inverse A368578).

Examples

			Table T(n, k) begins:
  n   n-th row
  --  ------------------
   0  0
   1  1
   2  2
   3  3, 4
   4  5
   5  6, 8
   6  7, 9
   7  10, 16
   8  11, 12, 17
   9  13, 18
  10  14, 19, 20
  11  15, 21, 32
  12  22, 24, 33
  13  23, 25, 34, 64
  14  26, 35, 36, 65
  15  27, 28, 37, 66
  16  29, 38, 40, 67, 68
		

Crossrefs

Programs

  • PARI
    \\ See Links section.

Formula

T(n, 1) = A345297(n).
T(n, A036497(n)) = A200947(n).

A201997 a(n) is the decimal value of the binary vector used to select terms of A075058 whose sum is n.

Original entry on oeis.org

0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20, 21, 22, 23, 24, 25, 26, 32, 33, 34, 36, 37, 38, 39, 40, 41, 42, 44, 45, 46, 48, 49, 50, 52, 53, 54, 55, 56, 57, 58, 60, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 76, 77, 78, 80, 81, 82, 84, 85, 86, 87
Offset: 0

Views

Author

Frank M Jackson, Dec 07 2011

Keywords

Examples

			For n=22, the binary vector when applied to A075058 is {0,1,0,1,1,0,...}, consequently 2+7+13=22. The decimal value of the binary vector (in ascending powers of 2) is 26, so a(22)=26.
		

Crossrefs

Programs

  • Mathematica
    prevprime[n_Integer] := (j=n; If[n==1, 1, While[!PrimeQ[j], j--]; j]); aprime[n_Integer] := (aprime[n]=prevprime[Sum[aprime[m], {m, 0, n - 1}] + 1]); gentable[n_Integer] := (m=n; ptable={0}; While[m!=0, (i=0; While[aprime[i]<=m && ptable[[i + 1]]!=1, (AppendTo[ptable, 0];i++)]; ptable[[i]] = 1; m = m - aprime[i - 1])]; ptable); decimal[n_Integer] := (gentable[n]; Sum[2^(k-1)*ptable[[k]], {k, 1, Length[ptable]}]); aprime[0]=1; Table[decimal[r], {r,0,100}]

Formula

Binary(a(n)) x A075058 = n, where x is the inner product and the binary vector is in ascending powers of 2 with infinite trailing zeros.

Extensions

Edited by N. J. A. Sloane, May 20 2023

A202618 a(n) is the smallest integer that is the sum of n distinct terms of A075058.

Original entry on oeis.org

0, 1, 4, 6, 19, 42, 89, 96, 289, 672, 1441, 2972, 6039, 12172, 24441, 48974, 98043, 196172, 392419, 784922, 1569939, 3139946, 6279987, 12560054, 25120201
Offset: 0

Views

Author

Frank M Jackson, Dec 21 2011

Keywords

Comments

Any nonnegative integer can be written as a sum of distinct terms of A075058. a(n) is the smallest integer that is the sum of n distinct terms of A075058 in the same way that A066352 gives a Pillai sequence for the sequence comprising 1 followed by all the primes.

Examples

			For n=5, the binary vector at A201997(54) is the smallest binary vector containing 5 1's and when applied to A075058 selects the integer 42. Consequently because 42=23+13+3+2+1 and 1,2,3,13,23 are all terms of the complete sequence A075058, a(5)=42.
		

Crossrefs

Programs

  • Mathematica
    prevprime[n_Integer] := (j=n;If[n==1, 1, While[!PrimeQ[j], j--]; j]);aprime[n_Integer] := (aprime[n]=prevprime[Sum[aprime[m], {m, 0, n - 1}]+1]);gentable[n_Integer] := (m=n;ptable={0};While[m!=0, (i=0;While[aprime[i]<=m && ptable[[i+1]]!=1, (AppendTo[ptable, 0];i++)];ptable[[i]] = 1;m=m-aprime[i - 1])];ptable);decimal[n_Integer] := (gentable[n];Sum[2^(k-1)*ptable[[k]], {k, 1, Length[ptable]}]);ones[n_Integer] :=(gentable[n];Sum[ptable[[k]], {k, 1, Length[ptable]}]);changeones[n_Integer] := (p = 0; While[ones[p] < n, p++]; p);aprime[0]=1;Table[changeones[r], {r, 0, 20}]

Formula

Find the smallest m such that binary(A201997(m)) x {1,1,1,...} = n, where x is the inner product, {1,1,1,1,...} is an infinite binary vector of 1's and binary(A201997(m)) a binary vector with infinite trailing zeros both in ascending powers of 2. Then a(n) = binary(m) x A075058, where x is the inner product and the binary vector is in ascending powers of 2 with infinite trailing zeros.

Extensions

Edited by N. J. A. Sloane, May 20 2023

A205598 The number n written using a minimizing algorithm in the base where the values of the places are 1 and primes.

Original entry on oeis.org

0, 1, 10, 11, 101, 110, 111, 1010, 1011, 1101, 1110, 1111, 10110, 10111, 11010, 11011, 11101, 11110, 11111, 101011, 101101, 101110, 101111, 110110, 110111, 111010, 111011, 111101, 111110, 111111, 1011110, 1011111
Offset: 0

Views

Author

Frank M Jackson, Feb 08 2012

Keywords

Comments

Any nonnegative number can be written as a sum of distinct primes + e, where e is 0 or 1 (see A007924, which uses a greedy algorithm for writing n). However in this sequence a(n) is generated by using a minimizing algorithm that gives the smallest binary vector for select members from the sequence Q = (1 union primes) that when summed gives n. Without the minimizing condition there is ambiguity -- for example, 8 = 7+1 = 5+3 = 5+2+1 has three representations.

Examples

			8 = 7+1 = 5+3 = 5+2+1, so a(8) = 1011.
		

Crossrefs

Programs

  • Mathematica
    aprime[n_] := If[n==0, 1, Prime[n]]; seqtable[l_] := (stable=Table[aprime[j], {j, 0, l}]; stable); inttable[p_] := (itable=Reverse[IntegerDigits[p, 2]]; itable); h=1; otable={0}; ttable={}; While[h<100, (inttable[h]; seqtable[Length[itable]-1]; test=itable.stable; If[!MemberQ[ttable, test], AppendTo[otable, h], Null]; AppendTo[ttable, test]; h++)]; IntegerString[otable, 2]

Formula

Let Q be the ordered sequence of (1 union primes), then a(n) x Q = n, where x is the inner product and the binary vector a(n) is in ascending powers of 2 with infinite trailing zeros.
Showing 1-10 of 10 results.