class Solution { public long solution(long n) { long answer = -1; long num1 = 0; long num2 = 0; while ( num2 < n) { num2 += num1 * 2 +1; if( num2 == n) { answer = (num1 + 1) * 2 + 1 + num2; break; } else { num1++; } } return answer; } }