A formula for the permanent of a matrix
where the sum is over all subsets of , and is the number of elements in . The formula can be optimized by picking the subsets so that only a single element is changed at a time (which is precisely a Gray code), reducing the number of additions from to .
It turns out that the number of disks moved after the th step in the tower of Hanoi is the same as the element which needs to be added or deleted in the th addend of the Ryser formula (Gardner 1988, Vardi 1991, p. 111).