const input = require("fs").readFileSync("/dev/stdin", "utf-8").trim();
let base = input;
let count = 0;
while(base > 0){
count++;
base = base - count;
}
if(count % 2 === 0){
console.log(`${count + base}/${1 + -base}`)
} else {
console.log(`${1 + -base}/${count + base}`)
}
우선 문제를 풀기 위해 규칙을 파악하는 것이 중요하다. base(input)값이 4라고 가정했을 때 while문을 통해 count++ 발생시킨다. 이때 count는 0에서 시작한다.
count++ 발생시키면서 base값을 base - count로 교체한다.
그럼 base값을 바탕으로 count를 구할 수 있고, count가 만약 2로 나눴을 때 나머지가 0이라면, 1 + -base(-2) / count(3) + base(-2)를 통해 값(3/1)을 구할 수 있다.
반대로 base(input)값이 7라고 가정하면,
count는 4까지 올라가게 된다. 그럼 count % 2 === 0 조건에 만족하기 때문에 count(4) + base(-3) / 1 + -base(-3)를 통해 1 / 4라는 결과값을 얻을 수 있게 된다.