Divide and conquer algorithm in discrete mathematics