Taken from https://www.topcoder.com/community/data-science/data-science-tutorials/mathematics-for-topcoders/ and translated to Swift Code for practice
Also added Tests to run directly on the playground thanks to the blog post http://initwithstyle.net/2015/11/tdd-in-swift-playgrounds/ made by @sshrpe
Just clone and run.
Pull request are welcome.