The end of Moore's law for CMOS technology has prompted the search for low-power computing alternatives, resulting in promising approaches such as nanomagnetic logic. However, nanomagnetic logic is unable to solve a class of interesting problems efficiently, as it only allows for forward computing, due to the need for clocking and/or thermal annealing. Here, we introduce nanomagnetic self-organizing logic gates that can dynamically satisfy their logical proposition, irrespective of whether the signal is applied to the traditional input or output terminals, thus allowing for reversible computing. We present a design of a self-organizing nand gate, the logically correct states of which are occupied equally in thermodynamical equilibrium, and illustrate its capabilities by implementing reversible Boolean circuitry to solve a two-bit factorization problem via numerical modeling. Our approach offers an alternative path to explore memcomputing, an unconventional computing paradigm the usefulness of which has already been demonstrated by solving a variety of hard combinatorial optimization problems.