Given the available data of month, year, and duration, the task is to iterate through the months for the specified duration and determine the month at the end of that period.
For instance, If the chosen month is March 2015 and the duration is 4 months, the desired outcome would be November 2014 - which is 4 months prior to the selected month.
How can this be best achieved?