inspired from https://math.stackexchange.com/questions/2134011 but modified so index starts from 1 as the original answer was for index starting from 0

get_upper_triangle_index(i, j, n)

Arguments

i

row index

j

column index

n

the size of squared matrix

Value

An index as integer number. Index starts from 1