Bonus Exercise 2

Encapsulated Exercise 2 in a method and used it to generate data based
on value n to populate the web service with json data. Web Service now
works as expected and returns proper output.