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.

Previous Showing 21-30 of 30 results.

A281227 Primes whose binary reflected Gray code representation is also the decimal representation of a prime.

Original entry on oeis.org

2, 53, 233, 281, 397, 521, 613, 673, 733, 773, 797, 829, 1049, 1129, 1433, 1553, 1697, 1933, 2129, 2237, 2273, 2281, 2437, 2521, 2557, 2617, 2729, 2969, 3121, 3181, 3413, 3457, 3517, 3637, 3709, 3761, 3881, 4337, 4357, 4729, 4733, 4877, 4889, 5101, 5657, 5813, 5857, 6113, 6133
Offset: 1

Views

Author

Indranil Ghosh, Jan 18 2017

Keywords

Examples

			521 is in the sequence because 521_10 = 1100001101_2 and both 521 and 1100001101 are prime numbers in base 10.
		

Crossrefs

Programs

  • Python
    from sympy import isprime
    def gray(n):
        return bin(n^(n//2))[2:]
    i=1
    j=1
    while j<=481:
        if isprime(i)==True and isprime(int(gray(i)))==True:
            print(str(j)+" "+str(i))
            j+=1
        i+=1

A281378 Palindromic numbers which are also palindromic in their binary reflected Gray code representation.

Original entry on oeis.org

0, 1, 2, 5, 6, 66, 77, 626, 5005, 7777, 22122, 64446, 87978, 399993, 1287821, 5614165, 5679765, 6407046, 6865686, 7107017, 8349438, 8547458, 282777282, 1220330221, 43474247434, 43833533834, 64630703646, 68622322686, 73855855837, 1249451549421, 2468208028642
Offset: 1

Views

Author

Indranil Ghosh, Jan 20 2017

Keywords

Examples

			626 is in the sequence because binary reflected Gray code for 626 is '1101001011' and both 626 and '1101001011' are palindromics.
		

Crossrefs

Programs

  • Mathematica
    Select[Range[10^7], And[Reverse@ # == # &@ IntegerDigits@ #, Reverse@ # == # &@ Abs[Prepend[Most@ #, 0] - #] &@ IntegerDigits[#, 2]] &] (* Michael De Vlieger, Jan 21 2017 *)
  • PARI
    lista(nn) = {my(v, w); for(k=0, nn, if((w=digits(k))==Vecrev(w) && (v=binary(bitxor(k, k>>1)))==Vecrev(v), print1(k, ", "))); } \\ Jinyuan Wang, Mar 01 2020
  • Python
    def G(n):
        return bin(n^(n//2))[2:]
    i=1
    j=1
    while j<=23:
        if  i==int(str(i)[::-1]) and G(i)==G(i)[::-1]:
            print(str(j)+" "+str(i))
            j+=1
        i+=1
    

Extensions

0 and more terms added by Chai Wah Wu, Jan 23 2017

A281497 Write n in binary reflected Gray code and sum the positions where there is a '1' followed immediately to the left by a '0', counting the rightmost digit as position 1.

Original entry on oeis.org

0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 2, 2, 1, 0, 0, 1, 2, 2, 0, 0, 1, 0, 3, 4, 3, 3, 2, 2, 1, 0, 0, 1, 2, 2, 3, 3, 4, 3, 0, 1, 0, 0, 2, 2, 1, 0, 4, 5, 6, 6, 4, 4, 5, 4, 3, 4, 3, 3, 2, 2, 1, 0, 0, 1, 2, 2, 3, 3, 4, 3, 4, 5, 4, 4, 6, 6, 5, 4, 0, 1, 2, 2, 0, 0, 1, 0, 3, 4, 3, 3, 2, 2, 1, 0, 5, 6, 7, 7, 8, 8, 9, 8, 5, 6, 5, 5, 7, 7, 6
Offset: 1

Views

Author

Indranil Ghosh, Jan 23 2017

Keywords

Examples

			For n = 12, the binary reflected Gray code for 12 is '1010'. In '1010', the position of '1' followed immediately to the left by a '0' counting from right is 2. So, a(12) = 2.
		

Crossrefs

Programs

  • Mathematica
    Table[If[Length@ # == 0, 0, Total[#[[All, 1]]]] &@ SequencePosition[ Reverse@ IntegerDigits[#, 2] &@ BitXor[n, Floor[n/2]], {1, 0}], {n, 120}] (* Michael De Vlieger, Jan 23 2017, Version 10.1, after Robert G. Wilson v at A003188 *)
  • Python
    def G(n):
        return bin(n^(n/2))[2:]
    def a(n):
        x=G(n)[::-1]
        s=0
        for i in range(1,len(x)):
            if x[i-1]=="1" and x[i]=="0":
                s+=i
        return s

Formula

a(n) = A049502(A003188(n)).

A351939 Irregular triangle read by rows: the n-th row contains the values 0..2^n-1 sorted first by Hamming weight and then by position in reflected Gray code.

Original entry on oeis.org

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

Views

Author

Valentin Bakoev, Feb 26 2022

Keywords

Comments

Values in the range 0..2^n-1 correspond to length n binary vectors. The Hamming weight is the number of 1 bits. Reflected Gray code is described in A003188 and A014550.
Rows can be subdivided into subsequences of vectors having the same Hamming weight. Within each subsequence, adjacent values will differ by 2 bits. For example, the subsequence of length 5 vectors with Hamming weight 2 is 00011, 00110, 00101, 01100, 01010, 01001, 11000, 10100, 10010, 10001 (in decimal 3, 6, 5, 12, 10, 9, 24, 20, 18, 17).
A revolving door algorithm can be used to enumerate values of the same weight in the required order. See Knuth ("Gray codes for combinations", p. 362) for additional information.

Examples

			Triangle T(n,k) begins:
n=0: 0;
n=1: 0, 1;
n=2: 0, 1, 2, 3;
n=3: 0, 1, 2, 4, 3, 6, 5, 7;
n=4: 0, 1, 2, 4, 8, 3, 6, 5, 12, 10, 9, 7, 13, 14, 11, 15;
n=5: 0, 1, 2, 4, 8, 16, 3, 6, 5, 12, 10, 9, 24, 20, 18, 17, 7, 13, 14, 11, 25, 26, 28, 21, 22, 19, 15, 27, 30, 29, 23, 31;
...
For row n = 3, the binary words of length 3 in reflected Gray code order are 000, 001, 011, 010, 110, 111, 101, 100. Arranging these by Hamming weight but otherwise preserving the order gives 000, 001, 010, 100, 011, 110, 101, 111. As decimal numbers these are 0, 1, 2, 4, 3, 6, 5, 7, which is row 3.
		

References

  • D. Knuth, The art of computer programming, Volume 4A: Combinatorial Algorithms, Part 1, Addison-Wesley, 2011.
  • F. Ruskey, Combinatorial Generation. Working Version (1j-CSC 425/520), 2003.

Crossrefs

Row sums are A006516.
Right border gives A000225.
Left border gives A000004.
T(n,n) gives A131577.
Cf. A000120 (Hamming weight), A003188, A014550 (reflected Gray code), A294648 (weight-lexicographic order).

Programs

  • Maple
    b:= proc(n) b(n):= `if`(n<2, n, Bits[Xor](n, b(iquo(n, 2)))) end:
    h:= proc(n) h(n):= add(i, i=Bits[Split](n)) end:
    T:= n-> sort([$0..2^n-1], (x,y)-> h(x)Alois P. Heinz, Mar 01 2022
  • Mathematica
    b[n_] := If[n < 2, n, BitXor[n, b[Quotient[n, 2]]]];
    h[n_] := DigitCount[n, 2, 1];
    T[n_] := SortBy[{h, b}][Range[0, 2^n - 1]];
    Table[T[n], {n, 0, 6}] // Flatten (* Jean-François Alcover, Oct 21 2022, after Alois P. Heinz *)
  • PARI
    row(n)=vecsort(vector(2^n, i, i--; bitxor(i, i>>1)), (x,y) -> cmp(hammingweight(x), hammingweight(y)))
    { for(n=0, 5, print(row(n))) } \\ Andrew Howroyd, Feb 28 2022

Formula

The n-th row is the concatenation of the subsequences g(n, 0), ..., g(n, n), where the subsequences are defined as follows:
g(n, 0) = (0),
g(n, n) = (2^n - 1),
g(n, k) = g(n-1, k) concatenate (g^r(n-1, k-1) + 2^(n-1)) for 0 < k < n.
In the above, g^r(n-1, k-1) + 2^(n-1) means the 2^(n-1) is added to each member of the subsequence g(n-1, k-1) in reversed order.

A279260 Numbers which are cyclops palindromic in their binary reflected Gray code representation.

Original entry on oeis.org

0, 6, 18, 90, 330, 1386, 5418, 21930, 87210, 349866, 1397418, 5593770, 22366890, 89483946, 357903018, 1431677610, 5726579370, 22906579626, 91625794218, 366504225450, 1466014804650, 5864063412906, 23456245263018, 93824997829290, 375299957762730, 1501199898159786, 6004799458421418
Offset: 0

Views

Author

Indranil Ghosh, Jan 17 2017

Keywords

Comments

Cyclops palindromic numbers in base 2 are numbers with middle bit 0, having equal number of 1's on both side of the 0. There is a single 0 bit in the middle and the total number of bits is odd. The middle '0' represents the eye of a cyclops.
a(n) mod 6 = 0.

Examples

			90 is in the sequence because the binary reflected Gray code representation of 90 is '1110111' which is a cyclops palindromic binary number.
		

Crossrefs

Partial sums of A071930.

Programs

  • PARI
    a(n)=(-2*(1+((-2)^n)-(2^(2*n+1))))/3 \\ Charles R Greathouse IV, Jun 29 2018
  • Python
    def a(n):
        return (-2*(1+((-2)**n)-(2**(2*n+1))))/3
    

Formula

a(n) = (-2*(1+((-2)^n)-(2^(2*n+1))))/3.

A280995 a(n) is the number produced when n is converted to binary reflected Gray code, the binary digits are reversed and the code is converted back to decimal.

Original entry on oeis.org

0, 1, 3, 1, 3, 7, 5, 1, 3, 11, 15, 7, 5, 13, 9, 1, 3, 19, 27, 11, 15, 31, 23, 7, 5, 21, 29, 13, 9, 25, 17, 1, 3, 35, 51, 19, 27, 59, 43, 11, 15, 47, 63, 31, 23, 55, 39, 7, 5, 37, 53, 21, 29, 61, 45, 13, 9, 41, 57, 25, 17, 49, 33, 1, 3, 67, 99, 35, 51, 115, 83, 19, 27, 91, 123, 59, 43
Offset: 0

Views

Author

Indranil Ghosh, Jan 19 2017

Keywords

Comments

a(n) = A003188(n) iff A014550(n) is palindromic.

Examples

			For n = 8, the binary reflected Gray code representation of n is '1100' which when reversed becomes '0011'; and 11_2 = 3_10. So, a(8) = 3.
		

Crossrefs

Programs

  • Python
    def a(n):
        return int(bin(n^(n/2))[2:][::-1],2)

A281014 Numbers with both prime number of 0's and prime number of 1's in their binary reflected Gray code representation.

Original entry on oeis.org

8, 12, 14, 16, 17, 19, 23, 24, 25, 27, 28, 29, 30, 33, 35, 39, 47, 49, 51, 55, 57, 59, 61, 64, 69, 73, 75, 77, 81, 83, 87, 89, 91, 93, 96, 101, 105, 107, 109, 112, 117, 120, 124, 126, 129, 131, 133, 135, 137, 139, 141, 143, 145, 147
Offset: 1

Views

Author

Indranil Ghosh, Jan 13 2017

Keywords

Comments

This sequence is the intersection of A280998 and A280999.

Examples

			27 is in the sequence as it is present in both the sequences A280998 and A280999.
		

Crossrefs

Programs

  • Mathematica
    Select[Range[150], And @@ PrimeQ[DigitCount[BitXor[#, Floor[#/2]], 2]] &] (* Amiram Eldar, May 01 2021 *)
  • PARI
    is(n)=isprime(logint(n,2)-hammingweight(bitxor(n, n>>1))+1) && isprime(hammingweight(bitxor(n, n>>1))) \\ Charles R Greathouse IV, Jan 13 2017

A281499 Write n in binary reflected Gray code, interchange the 1's and 0's, reverse the code and convert it back to decimal.

Original entry on oeis.org

1, 0, 0, 2, 4, 0, 2, 6, 12, 4, 0, 8, 10, 2, 6, 14, 28, 12, 4, 20, 16, 0, 8, 24, 26, 10, 2, 18, 22, 6, 14, 30, 60, 28, 12, 44, 36, 4, 20, 52, 48, 16, 0, 32, 40, 8, 24, 56, 58, 26, 10, 42, 34, 2, 18, 50, 54, 22, 6, 38, 46, 14, 30, 62, 124, 60, 28, 92, 76, 12, 44, 108, 100, 36, 4, 68, 84, 20, 52, 116, 112, 48, 16, 80, 64, 0, 32, 96, 104, 40, 8, 72, 88, 24, 56, 120
Offset: 0

Views

Author

Indranil Ghosh, Jan 23 2017

Keywords

Examples

			For n = 11, the binary reflected Gray code for 11 is '1110' which after interchanging the 1's and 0's becomes '0001', which on reversing further gives '1000'. Now, 1000_2 = 8_10. So, a(11) = 8.
		

Crossrefs

Programs

  • Mathematica
    Table[FromDigits[Reverse@ IntegerDigits[#, 2] &@ BitXor[n, Floor[n/2]] /. { 0 -> 1, 1 -> 0}, 2], {n, 0, 120}] (* Michael De Vlieger, Jan 23 2017 *)
  • Python
    def G(n):
        return bin(n^(n/2))[2:]
    def a(n):
        s=""
        x=G(n)
        for i in x:
            if i=="1":s+="0"
            else:s+="1"
        s=s[::-1]
        return int(s,2)

Formula

a(n) = A036044(A003188(n)).

A281553 Write n in binary reflected Gray code, rotate one binary place to the right and convert the code back to decimal.

Original entry on oeis.org

0, 1, 3, 1, 3, 7, 6, 2, 6, 14, 15, 7, 5, 13, 12, 4, 12, 28, 29, 13, 15, 31, 30, 14, 10, 26, 27, 11, 9, 25, 24, 8, 24, 56, 57, 25, 27, 59, 58, 26, 30, 62, 63, 31, 29, 61, 60, 28, 20, 52, 53, 21, 23, 55, 54, 22, 18, 50, 51, 19, 17, 49, 48, 16, 48, 112, 113, 49, 51, 115, 114, 50, 54, 118
Offset: 0

Views

Author

Indranil Ghosh, Jan 24 2017

Keywords

Comments

a(n) = A003188(n), iff the Elias delta code for n contains all 1's without any zeros (see the example section).

Examples

			For n = 5, the binary reflected Gray code for n is '111'. Rotating one binary place to the right , '111' gives back '111' again. 111_2 = 7_10. So, a(5) = 7. (For n = 5, A003188(n) = 7).
For n = 15, the binary reflected Gray code for n is '1000'. Rotating one binary place to the right, '1000' gives '0100'. 100_2 = 4_10. So, a(15) = 4.
		

Crossrefs

Programs

  • Python
    def rotation(n):
        x=bin(n^(n/2))[2:]
        return int(x[-1]+x[:-1],2)

A344345 Digitally balanced numbers in Gray code: numbers whose binary reflected Gray code has the same number of 0's as 1's.

Original entry on oeis.org

3, 8, 12, 14, 33, 35, 39, 47, 49, 51, 55, 57, 59, 61, 130, 132, 134, 136, 140, 142, 144, 152, 156, 158, 160, 176, 184, 188, 190, 194, 196, 198, 200, 204, 206, 208, 216, 220, 222, 226, 228, 230, 232, 236, 238, 242, 244, 246, 250, 517, 521, 523, 525, 529, 531, 535
Offset: 1

Views

Author

Amiram Eldar, May 15 2021

Keywords

Examples

			8 is a term since its Gray code, 1100, has 2 0's and 2 1's.
33 is a term since its Gray code, 110001, has 3 0's and 3 1's.
		

Crossrefs

Similar sequences: A031443 (binary), A210619 (Zeckendorf), A342727 (base i-1).

Programs

  • Mathematica
    gc[n_] := gc[n] = If[n <= 1, n, 2^(b = Floor@Log2[n]) + gc[2^(b + 1) - 1 - n]]; gcDigBalQ[n_] := Equal @@ DigitCount[gc[n], 2, {0, 1}]; Select[Range[500], gcDigBalQ]
Previous Showing 21-30 of 30 results.