##JavaScript (ES6), <s>30</s> 27 bytes *Saved 2 bytes thanks to kamoroso94* <!-- language: lang-js --> f=(n,k)=>n>0?f(n+~k,-~k):!n ###Test cases <!-- begin snippet: js hide: true console: true babel: false --> <!-- language: lang-js --> f=(n,k)=>n>0?f(n+~k,-~k):!n console.log('Testing truthy test cases'); console.log(f(1)) console.log(f(3)) console.log(f(6)) console.log(f(10)) console.log(f(15)) console.log(f(21)) console.log(f(55)) console.log(f(276)) console.log(f(1540)) console.log(f(2701)) console.log(f(5050)) console.log(f(7626)) console.log(f(18915)) console.log(f(71253)) console.log(f(173166)) console.log(f(222111)) console.log(f(303031)) console.log(f(307720)) console.log(f(500500)) console.log(f(998991)) console.log('Testing falsy test cases'); console.log(f(2)) console.log(f(4)) console.log(f(5)) console.log(f(7)) console.log(f(8)) console.log(f(9)) console.log(f(11)) console.log(f(16)) console.log(f(32)) console.log(f(50)) console.log(f(290)) console.log(f(555)) console.log(f(4576)) console.log(f(31988)) console.log(f(187394)) console.log(f(501500)) console.log(f(999999)) <!-- end snippet --> ###Non-recursive version (ES7), 19 bytes Port of [Adnan's answer][1]. <!-- language: lang-js --> x=>(8*x+1)**.5%1==0 [1]: https://codegolf.stackexchange.com/a/122091/58563