add triangular algorithm