More recursive algorithms (Discrete Math related)