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

A128173 Numbers in ternary reflected Gray code order.

Original entry on oeis.org

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

Views

Author

Ralf Stephan, May 09 2007

Keywords

Crossrefs

Programs

  • Maple
    A128173 := proc(nmax) local K,tmp,n3,n,r,c,t,a ; n3 := 3 ; n := 1 ; K := linalg[matrix](n3,1,[[0],[1],[2]]) ; while n3 < nmax do n3 := n3*3 ; n := n+1 ; tmp := K ; K := linalg[extend](K,2*n3/3,1,0) ; K := linalg[copyinto](tmp,K,1+n3/3,1) ; K := linalg[copyinto](tmp,K,1+2*n3/3,1) ; for r from 1 to n3 do K[r,n] := floor((r-1)/(n3/3)) ; od ; for r from n3/3+1 to n3/2 do for c from 1 to n do t := K[r,c] ; K[r,c] := K[n3+1-r,c] ; K[n3+1-r,c] := t ; od ; od ; od ; a := [] ; for r from 1 to n3 do a := [op(a), add( K[r,c]*3^(c-1),c=1..n) ] ; od ; a ; end: A128173(30) ; # R. J. Mathar, Jun 17 2007
  • Mathematica
    a[n_] := Module[{v, r, i}, v = IntegerDigits[n, 3]; r = 0; For[i = 1, i <= Length[v], i++, If[r == 1, v[[i]] = 2 - v[[i]]]; r = Mod[r + v[[i]], 2]]; FromDigits[v, 3]];
    a /@ Range[0, 100] (* Jean-François Alcover, Jul 18 2020, after Kevin Ryde *)
  • PARI
    a(n) = my(v=digits(n,3),r=Mod(0,2)); for(i=1,#v, if(r,v[i]=2-v[i]); r+=v[i]); fromdigits(v,3); \\ Kevin Ryde, May 21 2020

Extensions

More terms from R. J. Mathar, Jun 17 2007
Offset changed to 0 by Alois P. Heinz, Feb 23 2018

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

A381668 Ternary modular Gray code for n written in base 3.

Original entry on oeis.org

0, 1, 2, 12, 10, 11, 21, 22, 20, 120, 121, 122, 102, 100, 101, 111, 112, 110, 210, 211, 212, 222, 220, 221, 201, 202, 200, 1200, 1201, 1202, 1212, 1210, 1211, 1221, 1222, 1220, 1020, 1021, 1022, 1002, 1000, 1001, 1011, 1012, 1010, 1110, 1111, 1112, 1122, 1120, 1121
Offset: 0

Views

Author

Joshua Chester, Mar 03 2025

Keywords

Comments

Similar to binary Gray code in that a(n) differs from a(n+1) by one digit, including the last number with a given number of digits compared to a(0).

Crossrefs

Programs

  • PARI
    a(n) = my(v=digits(n, 3)); forstep(i=#v, 2, -1, v[i]=(v[i]-v[i-1])%3); fromdigits(v, 10); \\ (after A105530) - Andrew Howroyd, Mar 03 2025

Formula

a(n) = A007089(A105530(n)).
Showing 1-4 of 4 results.