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

A143245 Primes in A098957.

Original entry on oeis.org

3, 5, 7, 13, 11, 17, 29, 23, 31, 41, 37, 53, 61, 43, 47, 97, 113, 73, 101, 67, 83, 107, 71, 127, 193, 233, 197, 229, 181, 173, 131, 163, 227, 251, 199, 167, 151, 223, 257, 449, 353, 337, 433, 409, 313, 421, 277, 373, 269, 461, 349, 509, 307, 331, 491, 283, 443
Offset: 1

Views

Author

Roger L. Bagula and Gary W. Adamson, Oct 21 2008

Keywords

Crossrefs

Cf. A098957.

Programs

  • Maple
    brev:= proc(n) local L;
      L:= convert(n,base,2);
      add(L[-i]*2^(i-1),i=1..nops(L))
    end proc:
    select(isprime, [seq(brev(ithprime(i)),i=1..100)]); # Robert Israel, Apr 03 2019
  • Mathematica
    GrayCodeList[k_] := Module[{b = IntegerDigits[k, 2], i}, Do[ If[b[[i - 1]] == 1, b[[i]] = 1 - b[[i]]], {i, Length[b], 2, -1} ]; b ]; a[n_] = GrayCodeList[Prime[n]]; a0 = Table[Sum[a[n][[m + 1]]*2^m, {m, 0, Length[a[n]] - 1}], {n, 1, 200}]; Flatten[Table[If[PrimeQ[a0[[n]]], a0[[n]], {}], {n, 1, 200}]]
  • PARI
    forprime(p=2, 1e3, v=binary(p); s=0; forstep(i=#v, 1, -1, s+=s+v[i]); if(isprime(s),print1(s", "))) \\ Charles R Greathouse IV, Nov 07 2011

A235027 Reverse the bits of prime divisors of n (with 2 -> 2), and multiply together: a(0)=0, a(1)=1, a(2)=2, a(p) = revbits(p) for odd primes p, a(u*v) = a(u) * a(v) for composites.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13, 12, 11, 14, 15, 16, 17, 18, 25, 20, 21, 26, 29, 24, 25, 22, 27, 28, 23, 30, 31, 32, 39, 34, 35, 36, 41, 50, 33, 40, 37, 42, 53, 52, 45, 58, 61, 48, 49, 50, 51, 44, 43, 54, 65, 56, 75, 46, 55, 60, 47, 62, 63, 64, 55, 78, 97
Offset: 0

Views

Author

Antti Karttunen, Jan 02 2014

Keywords

Comments

This is not a permutation of integers: a(25) = 25 = 5*5 = a(19) is the first case which breaks the injectivity. However, the first 24 terms are equal with A057889, which is a GF(2)[X]-analog of this sequence and which in contrary to this, is bijective. This stems from the fact that the set of irreducible GF(2)[X] polynomials (A014580) is closed under bit-reversal (A056539), while primes (A000040) are not.
Sequence A290078 gives the positions n where the ratio a(n)/n obtains new record values.
Note, instead of A056539 we could as well use A057889 to reverse the bits of n, and also A030101 when restricted to odd primes.

Examples

			a(33) = a(3*11) = a(3) * a(11) = 3 * 13 = 39 (because 3, in binary '11', stays same when reversed, while 11 (eleven), in binary '1011', changes to '1101' = 13).
		

Crossrefs

A235028 gives the fixed points. A235030 numbers such that n <> a(a(n)), or equally A001222(a(n)) > A001222(n). A235145 the number of iterations needed to reach a fixed point or cycle of 2, A235146 its records.

Programs

  • Mathematica
    f[p_, e_] := IntegerReverse[p, 2]^e; f[2, e_] := 2^e; a[1] = 1; a[n_] := Times @@ f @@@ FactorInteger[n]; Array[a, 100, 0] (* Amiram Eldar, Sep 03 2023 *)
  • PARI
    revbits(n) = fromdigits(Vecrev(binary(n)), 2);
    a(n) = {my(f = factor(n)); for (k=1, #f~, if (f[k,1] != 2, f[k,1] = revbits(f[k,1]););); factorback(f);} \\ Michel Marcus, Aug 05 2017

Formula

Completely multiplicative with a(0)=0, a(1)=1, a(p) = A056539(p) for primes p (which maps 2 to 2, and reverses the binary representation of odd primes), and a(u*v) = a(u) * a(v) for composites.
Equally, after a(0)=0, a(p * q * ... * r) = A056539(p) * A056539(q) * ... * A056539(r), for primes p, q, etc., not necessarily distinct.
a(0)=0, a(1)=1, a(n) = A056539(A020639(n)) * a(n/A020639(n)).

A265326 n-th prime minus its binary reversal.

Original entry on oeis.org

1, 0, 0, 0, -2, 2, 0, -6, -6, 6, 0, -4, 4, -10, -14, 10, 4, 14, -30, -42, 0, -42, -18, 12, 30, 18, -12, 0, 18, 42, 0, -62, -8, -70, -20, -82, -28, -34, -62, -8, -26, 8, -62, 62, 34, -28, 8, -28, 28, 62, 82, -8, 98, 28, 0, -186, -84, -210, -60
Offset: 1

Views

Author

Max Barrentine, Dec 07 2015

Keywords

Comments

a(n) = 0 iff A000040(n) is in A016041. - Altug Alkan, Dec 07 2015
The graph consists of a succession of parallelograms. The parallelograms end when there is a long run of mostly positive terms followed by a long run of mostly negative terms. The places where the successive parallelograms end are the primes just before a power of 2: 3, 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381, 32749, ..., which are terms with indices 2, 4, 6, 11, 18, 31, 54, 97, 172, 309, 564, 1028, 1900, 3512, 6542, 12251, 23000, 43390, 82025, ... (see A014234 and A007053). - N. J. A. Sloane, May 29 2016

Examples

			n=5: prime(5) = 11_10 = 1011_2, reversing gives 1101_2 = 13_10, so a(5) = 11-13 = -2.
		

Crossrefs

Programs

  • Maple
    revdigs:= proc(n) local L, j;
      L:= convert(n,base,2);
      add(L[-j]*2^(j-1),j=1..nops(L))
    end proc:
    map(t -> t - revdigs(t),  select(isprime, [2,seq(i,i=3..1000,2)])); # Robert Israel, Dec 08 2015
  • Mathematica
    Table[# - FromDigits[Reverse@ IntegerDigits[#, 2], 2] &@ Prime@ n, {n, 60}] (* Michael De Vlieger, Dec 09 2015 *)
  • PARI
    a098957(n) = my(v=binary(prime(n)), s); forstep(i=#v, 1, -1, s+=s+v[i]); s
    a(n) = prime(n) - a098957(n); \\ Altug Alkan, Dec 07 2015

Formula

a(n) = A000040(n) - A098957(n).
a(n) = A055945(A000040(n)). - Michel Marcus, Dec 08 2015

A143257 Reverse binary expansion of the factorial numbers.

Original entry on oeis.org

1, 1, 1, 3, 3, 15, 45, 441, 441, 3213, 16059, 172569, 517671, 6695325, 43746885, 903732249, 903732249, 14611840389, 110769926061, 1248788195355, 12439562858721, 154437141889677, 1902100636851663, 51339101124195573, 255363550208935617, 4458722921105347251
Offset: 0

Views

Author

Roger L. Bagula and Gary W. Adamson, Oct 21 2008

Keywords

Crossrefs

Programs

  • Maple
    A143257 := proc(n)
        A030101(n!) ;
    end proc:
    seq(A143257(n),n=0..10) ; # R. J. Mathar, Mar 10 2015
  • Mathematica
    a[n_] := FromDigits[ Reverse@ IntegerDigits[n!, 2], 2];
    Array[a, 23] (* Robert G. Wilson v, Mar 11 2015 *)
  • PARI
    a(n) = my(v=binary(n!), s); forstep(i=#v, 1, -1, s+=s+v[i]); s \\ Michel Marcus, May 18 2013

Formula

a(n) = A030101(n!).

Extensions

Edited and renamed by Michel Marcus, May 18 2013

A159006 Transformation of prime(n): flip digits in the binary representation, revert the sequence of digits, and convert back to decimal.

Original entry on oeis.org

2, 0, 2, 0, 2, 4, 14, 6, 2, 8, 0, 22, 26, 10, 2, 20, 8, 16, 30, 14, 54, 6, 26, 50, 60, 44, 12, 20, 36, 56, 0, 62, 110, 46, 86, 22, 70, 58, 26, 74, 50, 82, 2, 124, 92, 28, 52, 4, 56, 88, 104, 8, 112, 32, 254, 62, 158, 30, 174, 206, 78, 182, 102, 38, 198, 134, 90, 234, 74, 138, 242
Offset: 1

Views

Author

Keywords

Comments

Write the n-th prime in binary as in A004676. Change all 0's to 1's and all 1's to 0's to reach A145382. Read the binary digits from right to left. a(n) is the decimal equivalent of the result.
All entries are even, i.e., members of A005843.

Examples

			37->100101->change digits 011010->read from right to left 010110->22 281->100011001->change digits 011100110->read from right to left 011001110->206
		

Crossrefs

Programs

  • Maple
    P:=proc(i) local a,b,j,k,n; for n from 1 by 1 to i do a:=convert(ithprime(n), binary); j:=length(a); b:=convert(a,string); k:=""; while j>0 do if substring(b,j)="1" then k:=cat(k,"0"); else k:=cat(k,"1"); fi; j:=j-1; od; a:=convert(k,decimal,binary); print(a); od; end: P(100);
  • Mathematica
    FromDigits[Reverse@ BitNot@ IntegerDigits[#, 2] + 2, 2] & /@ Prime@ Range@ 71 (* Michael De Vlieger, Apr 22 2015 *)
  • PARI
    a(n)=fromdigits(Vecrev(apply(n->1-n,binary(prime(n)))),2) \\ Charles R Greathouse IV, Apr 22 2015
    
  • Python
    from sympy import prime
    def A159006(n): return -int((s:=bin(prime(n))[-1:1:-1]),2)-1+2**len(s) # Chai Wah Wu, Feb 04 2022

Formula

a(n) = A036044(prime(n)). - Michel Marcus, Apr 22 2015

Extensions

Edited by R. J. Mathar, Apr 06 2009

A351528 Prime numbers ordered by their binary reversal.

Original entry on oeis.org

2, 3, 5, 7, 13, 11, 17, 29, 19, 23, 31, 41, 37, 53, 61, 43, 59, 47, 97, 113, 73, 89, 101, 109, 67, 83, 107, 71, 103, 79, 127, 193, 241, 137, 233, 197, 229, 149, 181, 173, 157, 131, 163, 227, 211, 179, 139, 251, 199, 167, 151, 239, 223, 191, 257, 449, 353, 401
Offset: 1

Views

Author

Rémy Sigrist, Feb 13 2022

Keywords

Comments

See A104154 for the base-10 variant.
Mersenne primes (A000668) and Fermat primes (A019434) appear at their natural position.

Examples

			The first terms, alongside their binary and reverse binary expansions, are:
  n   a(n)  bin(a(n))  bin(rev(a(n)))
  --  ----  ---------  --------------
   1     2         10               1
   2     3         11              11
   3     5        101             101
   4     7        111             111
   5    13       1101            1011
   6    11       1011            1101
   7    17      10001           10001
   8    29      11101           10111
   9    19      10011           11001
  10    23      10111           11101
  11    31      11111           11111
		

Crossrefs

Programs

  • Mathematica
    SortBy[Select[Range[2^9], PrimeQ], IntegerReverse[#, 2] &] (* Amiram Eldar, Feb 15 2022 *)
  • PARI
    rev(n) = fromdigits(Vecrev(binary(n)), 2)
    print (vecsort(primes([1, 2^9]), (p,q)->rev(p)-rev(q))[1..58])
    
  • Python
    from itertools import count, islice
    from sympy import primerange
    def A351528_gen(): # generator of terms
        yield from (int(d[::-1],2) for l in count(1) for d in sorted(bin(m)[:1:-1] for m in primerange(2**(l-1),2**l)))
    A351528_list = list(islice(A351528_gen(),20)) # Chai Wah Wu, Feb 17 2022

A143250 Reverse binary expansion of the Fibonacci numbers.

Original entry on oeis.org

1, 1, 1, 3, 5, 1, 11, 21, 17, 59, 77, 9, 151, 317, 281, 879, 1507, 389, 5441, 5835, 4309, 31313, 18427, 1197, 69961, 71863, 68605, 423129, 354527, 83155, 1534501, 2633505, 1177835, 7573621, 9646897, 887751, 20771357, 38811817, 18203279, 110884035
Offset: 1

Views

Author

Roger L. Bagula and Gary W. Adamson, Oct 21 2008

Keywords

Comments

Old name was "Sequence of sum of Gray code Binary digits for Fibonacci sequence A000045: a(n) = GrayCodeBinarySum(A000045(n))".

Crossrefs

Programs

  • Magma
    [Seqint(Reverse(Intseq(Fibonacci(n),2)),2): n in [1..40]]; // Bruno Berselli, May 01 2013
  • Mathematica
    GrayCodeList[k_] := Module[{b = IntegerDigits[k, 2], i}, Do[ If[b[[i - 1]] == 1, b[[i]] = 1 - b[[i]]], {i, Length[b], 2, -1} ]; b ]; a[n_] = GrayCodeList[Fibonacci[n]]; a0 = Table[Sum[a[n][[m + 1]]*2^m, {m, 0, Length[a[n]] - 1}], {n, 1, 200}]
    Table[FromDigits[Reverse[IntegerDigits[Fibonacci[n], 2]], 2], {n, 40}] (* Bruno Berselli, May 01 2013 *)
  • PARI
    a(n) = {my(v=binary(fibonacci(n)), s); forstep(i=#v, 1, -1, s+=s+v[i]); return (s);} \\ Michel Marcus, May 01 2013
    

Formula

a(n) = Decimal(reverse(Binary(A000045(n)))).

Extensions

Edited and new name by Michel Marcus, May 01 2013
Showing 1-7 of 7 results.