A white dwarf is essentially a degenerate electron gas, in which pressure of degenerate electrons supports gravitational pressure. As a simplified model of such an object, consider a spherical star of ideal gas consisting of electrons and completely ionized hydrogen atoms, and of constant density. Radius of star is $R$, Mass of star is $M$, $N$ = number of electrons.
Consider the electrons to be ultra-relativistic. Density of star is given to be ${10}^{12}\, \mathrm{kg \cdot m}^{-3}$ . What is the critical mass for which the dwarf can be in equilibrium?
I am trying to find the gravitational pressure and the Fermi pressure due to the electrons, and then I will equate them. I have successfully calculated the gravitational pressure, but to calculate Fermi pressure, I need total energy to Pauli Exclusion principle applied to electrons. The total energy is coming to be a function of $N$, and due to some mistake (which I do not know, where am I making), the radius term is not cancelling on both sides (which should). How to calculate total energy due to Pauli exclusion principle?