https://foxstack.blogspot.com/2022/03/calculate-nth-term-hackerrank-problem.html