BAEKJOON/JavaScript

[BAEKJOON] 한수 (1065번)

피리부는남자 2022. 3. 30. 11:17
// const input  = require("fs").readFileSync("/dev/stdin").toString();
const input = "500".toString();

function arithmeticSequence(input) {
    let testCase = Number(input);
    let answer   = 0;

    for(let i = 1; i <= testCase; i++) {
        let strTestCase = i.toString();

        if(strTestCase < 100) {
            answer++;
            continue;
        } else {
            if( (strTestCase[0] - strTestCase[1]) === (strTestCase[1] - strTestCase[2]) ) {
                answer++;
                continue;
            }
        }
    }
    console.log(answer);
}

arithmeticSequence(input);