mathematics and probability, recursion and dp