The well known Nakano-Nishijima-Gell-Mann (NNG) formula relates certain quantum numbers of elementary particles to their charge number. This equation, which phenomenologically introduces the quantum numbers $I_z$ (isospin), $S$ (strangeness), etc., is constructed using group theory with real numbers $mathbb{R}$. But, using a discrete Galois field $mathbb{F}_p$ instead of $mathbb{R}$ and assuring the fundamental invariance laws such as unitarity, Lorentz invariance, and gauge invariance, we derive the NNG formula deductively from Meson (two quarks) and Baryon (three quarks) representations in a unified way. Moreover, we show that quark confinement ascribes to the inevitable fractionality caused by coprimeness between half-integer (1/2) of isospin and number of composite particles (e.g. three).