staircase calculation