A hexagonal closed packing (hcp) unit cell has an ABAB type of packing. For calculating the packing fraction we require the volume of the unit cell.
Volume of hcp lattice = (Base area) ⋅
(Height of unit cell)
Each hexagon has a side = 2⋅r
Base area = 6
(Area of small equilateral triangles making up the hexagon)
=6⋅3–√4×(2r)2
=6⋅3–√⋅r2
Hence, volume =6⋅3–√⋅r2
(Height of unit cell)
This is the point where I am stuck. How do I find out the height of the unit cell?

I searched in textbooks and found out that height =4r⋅23−−√