Calculating the value of k