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.

A105529 Given a list of ternary numbers, interpret each as a ternary modular Gray code number, then convert to decimal.

Original entry on oeis.org

0, 1, 2, 4, 5, 3, 8, 6, 7, 13, 14, 12, 17, 15, 16, 9, 10, 11, 26, 24, 25, 18, 19, 20, 22, 23, 21, 40, 41, 39, 44, 42, 43, 36, 37, 38, 53, 51, 52, 45, 46, 47, 49, 50, 48, 27, 28, 29, 31, 32, 30, 35, 33, 34, 80, 78, 79, 72, 73, 74, 76, 77, 75
Offset: 0

Views

Author

Gary W. Adamson, Apr 11 2005

Keywords

Examples

			a(9) = 13 since Ternary 100 (9 decimal) interpreted as Ternary Gray code = 13.
		

Crossrefs

Cf. A105530 (inverse), A128173 (ternary reflected), A006068 (binary), A226134 (decimal modular), A007089.

Programs

  • Mathematica
    a[n_] := Module[{v = IntegerDigits[n, 3]}, Do[v[[i]] = Mod[v[[i]]+v[[i-1]], 3], {i, 2, Length[v]}]; FromDigits[v, 3]];
    Table[a[n], {n, 0, 62}] (* Jean-François Alcover, Jun 26 2023, after Kevin Ryde *)
  • PARI
    a(n) = my(v=digits(n,3)); for(i=2,#v, v[i]=(v[i]+v[i-1])%3); fromdigits(v,3); \\ Kevin Ryde, May 23 2020

Extensions

More terms from Sean A. Irvine, Feb 09 2012
Comments by Gary W. Adamson moved to A105530 where they better apply. - Kevin Ryde, May 30 2020

A098488 Decimal modular Gray code for n.

Original entry on oeis.org

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

Views

Author

Jaume Simon Gispert (jaume(AT)nuem.com), Sep 10 2004

Keywords

Comments

This is another decimal Gray code that considers that the distance between 9 and 0 is 1. Cyclic for (left-zero-padded) groups of n digits.

Crossrefs

Cf. A003100.
Cf. A226134 (inverse).

Programs

  • Haskell
    import Data.List (elemIndex); import Data.Maybe (fromJust)
    a098488 = fromJust . (`elemIndex` a226134_list)
    -- Reinhard Zumkeller, Jun 03 2013
    
  • Maple
    # insert 10 into the second argument of the gray(.,.) function in A105530. - R. J. Mathar, Mar 10 2015
  • Mathematica
    AltGray[In_] := { tIn = IntegerDigits[In]; Ac = 0; Do[tIn[[z]] = Mod[tIn[[z]] - Ac, 10]; Ac += tIn[[z]], {z, 1, Length[tIn]}]; FromDigits[tIn, 10] }
  • PARI
    a(n) = my(v=digits(n)); forstep(i=#v,2,-1, v[i]=(v[i]-v[i-1])%10); fromdigits(v); \\ Kevin Ryde, May 15 2020

A247891 a(n) is Gray-coded in base 4 into n.

Original entry on oeis.org

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

Views

Author

Alex Ratushnyak, Sep 26 2014

Keywords

Comments

Permutation of nonnegative numbers.

Crossrefs

Cf. A006068 (base 2), A105529 (base 3), A226134 (base 10).

Programs

  • Python
    def basexor(a, b, base):
      result = 0
      digit = 1
      while a or b:
        da = a % base
        db = b % base
        a //= base
        b //= base
        sum = (da+db) % base
        result += sum * digit
        digit *= base
      return result
    base = 4  #  2 => A006068, 3 => A105529, 10 => A226134
    for n in range(129):
      a = n
      b = n//base
      while b:
        a = basexor(a,b, base)
        b //= base
      print(a, end=', ')
    
  • Python
    def xor4(x, y): return 4*xor4(x//4, y//4) + (x+y)%4 if x else y
    def a(n): return xor4(n, a(n//4)) if n else 0 # David Radcliffe, Jun 22 2025

Formula

a(n) = n XOR4 [n/4] XOR4 [n/16] XOR4 [n/64] ... XOR4 [n/4^m] where m = [log(n)/log(4)], [x] is integer floor of x, and XOR4 is a base 4 analog of binary exclusive-OR operator.
In other words, a(n) = n + [n/4] + [n/16] + ... where addition is performed in base 4 without carries. - David Radcliffe, Jun 22 2025
Showing 1-3 of 3 results.