Design algorithms involving branching and iteration to solve specific classes of mathematical problems