I need help with writing a formula for step 1 and step 2 . The…