The present application solves the problem that with regards to technology for generating a code of a maximum-length linearly recurring sequence, conventionally, it was not indicated that a complement reverse (CR) sequence is present when n is an ordinary odd number, and so only by means of an extremely inefficient method was it possible to generate a CR sequence having a long sequence length. In the present application, a code generating device (100) that generates a CR sequence contained in a de Bruijn sequence having a length of 2(2p+1) is such that first, a directed Eulerian graph (Gn0) is generated using a de Bruijn graph (Gn) in which a plurality of vertices are respectively joined by edges, and then a CR graph archetype and CR graph are generated, and finally a CR sequence is generated. By means of this algorithm, it is possible to uniquely convert an Eulerian circuit on a CR graph to a CR graph. Here, when generating CR graph, each of a plurality of vertices including at least one neutral vertex conta