Density functionals and Kohn-Sham potentials with minimal wavefunction preparations on a quantum computer