login
The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A091299 Number of (directed) Hamiltonian paths (or Gray codes) on the n-cube. 8
2, 8, 144, 91392, 187499658240 (list; graph; refs; listen; history; text; internal format)
OFFSET

1,1

COMMENTS

More precisely, this is the number of ways of making a list of the 2^n nodes of the n-cube, with a distinguished starting position and a direction, such that each node is adjacent to the previous one. The final node may or may not be adjacent to the first.

REFERENCES

M. Gardner, Knotted Doughnuts and Other Mathematical Entertainments. Freeman, NY, 1986, p. 24.

LINKS

Table of n, a(n) for n=1..5.

Eric Weisstein's World of Mathematics, Hamiltonian Path

Eric Weisstein's World of Mathematics, Hypercube Graph

EXAMPLE

a(1) = 2: we have 1,2 or 2,1. a(2) = 8: label the nodes 1, 2, ..., 4. Then the 8 possibilities are 1,2,3,4; 1,3,4,2; 2,3,4,1; 2,1,4,3; etc.

PROG

# A Python function that calculates A091299[n] from Janez Brank.

def CountGray(n):

    def Recurse(unused, lastVal, nextSet):

        count = 0

        for changedBit in range(0, min(nextSet + 1, n)):

            newVal = lastVal ^ (1 << changedBit)

            mask = 1 << newVal

            if unused & mask:

                if unused == mask:

                    count += 1

                else:

                    count += Recurse(

                        unused & ~mask, newVal, max(nextSet, changedBit + 1)

                    )

        return count

    count = Recurse((1 << (1 << n)) - 2, 0, 0)

    for i in range(1, n + 1):

        count *= 2 * i

    return max(1, count)

[CountGray(n) for n in range(1, 4)]

CROSSREFS

Equals A006069 + A006070. Divide by 2^n to get A003043.

Cf. A003042, A066037, A091302, A284673.

Sequence in context: A009817 A124105 A079613 * A307326 A007314 A102099

Adjacent sequences:  A091296 A091297 A091298 * A091300 A091301 A091302

KEYWORD

nonn,hard,more

AUTHOR

N. J. A. Sloane, Feb 20 2004

EXTENSIONS

a(5) from Janez Brank (janez.brank(AT)ijs.si), Mar 02 2005

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified May 14 02:53 EDT 2021. Contains 343868 sequences. (Running on oeis4.)