Have the formula agreeing with the first test case. Continuing on…