Hackerrank - Manasa and Stones

Problem Statement
A description of the problem can be found on Hackerrank.

Solution
The result is set of leaves of a tree in depth n with a stating root 0 and every child is calculated as: parent + a and parent + b.

I created solution in:

All solutions are also available on my GitHub.

Java

JavaScript

Scala

Ruby