Mathematic Exercise Algorithm