18주차 개발일지

이동규·2023년 8월 21일

function solution(n){
    let answer = '';
    for (let index = 1; index <=n; index++) {
        if(index % 2 ===1){
            answer +='수';
            continue;
        }
        answer+='박'   
    }
    return answer;
}

function solution(left, right) {
    let answer = 0;
    for (let index = left; index <= right; index++){
        let cnt =0;
        for (let j = 1; j * j <= index; j++) {
           if (j * j === index) ++cnt;
           
           else if (index % j === 0) cnt+=2;
        }
        answer += cnt %2 ===1 ?index:-index;   
    }
    return answer;
}

function solution(s){
    return s
      .split("")
      .sort()
      .reverse()
      .join("");
  }

function solution(price, money, count){
    let temp  = price;
  
    for (let index = 1; index <= count; index++) {
        price= temp* index;
        money -=price;
    }
  
    if (money <0) {
        return -money;    
    }
    return 0;
}

0개의 댓글