cap gain Q

we bought a house as a primary residence in1997, lived in it for 6 years. then turned it to a rental property., up to the time we sold it in Jan 2021, how is the gain calculated?

How is depreciation recapture calculated?