@dilipandey

I think you're missing the point here. This is homework and OP can't use a formula that hasn't been taught yet. I wouldn't have posted a solution had I realized at the time that it was homework.