Reflective reconfigurable intelligent surface (RIS) technology is regarded as an innovative, cost- and power-effective solution that aims at influencing the wireless channel through controlled scattering. The technology can be realized by using metamaterials and/or resonant elements that scatter electromagnetic waves with a configurable phase shift. Most of the previous work on beamforming techniques for RIS assumes ideal hardware and, thus, continuous phase shifts. However, hardware constraints limit the phase shift resolution, manifested into the amount of discrete phase shifts that can be configured into each RIS element. This paper aims to offer a discrete phase shift beamforming algorithm for reflective RISs that targets minimization of the quantization error resulting from discretization of continuous phase shifts. The beamforming solution proves to be optimal under perfect channel knowledge for any discrete set of uniformly distributed phase shifts. The required complexity to find the optimal beamforming vector for our approach is found to be linear with the number of RIS elements, the minimum needed to obtain optimal results. Simulated behavior is validated by measurements, showing robustness against angle misalignments and distance variations.