Hootsuite Interview Question

Implementing the algorithm given the mathematical formula.