We make two recursive calls , so reduce k by 2.
k -= 2 ; var mid = parseInt ( ( l + r ) / 2 ) ; [ a [ mid - 1 ] , a [ mid ] ] = [ a [ mid ] , a [ mid - 1 ] ] ; unsort ( l , mid , a ) ; unsort ( mid , r , a ) ; } function arrayWithKCalls ( n ) { if ( k % 2 == 0 ) { document . write ( " " ) ; return ; }