arranging coins

Solutions on MaxInterview for arranging coins by the best coders in the world

showing results for - "arranging coins"
Santino
28 Jun 2016
1var arrangeCoins = function(n) {
2    let i = 1, j = 0
3    
4    while(n > 0){
5        n -= i
6        j++
7        i++
8    }
9    
10    if(n === 0) return j
11    else return --j
12};