- In the framework of Kohn-Sham density-functional theory, systems with ground-state densities that are not pure-state v-representable in the non-interacting reference system (PSVR) occur frequently. In the present contribution, a new algorithm, which allows the solution of such systems, is proposed. It is shown that the use of densities which do not correspond to a ground state of their non-interacting reference system is forbidden. As a consequence, the proposed algorithm considers only non-interacting ensemble v-representable densities. The Fe atom, a well-known non-PSVR system, is used as an illustration. Finally, the problem is analyzed within finite temperature density-functional theory, where the physical significance of fractional occupations is exposed and the question of why degenerate states can be unequally occupied is resolved.