[프로그래머스] Lv.0 등차수열의 특정한 항만 더하기.java

hgghfgf·2023년 5월 27일
0

프로그래머스

목록 보기
93/227

등차수열의 특정한 항만 더하기.java

class Solution {
    public int solution(int a, int d, boolean[] included) {
        int answer = 0;
        
        for(int i=0; i<included.length; i++){
            if(included[i]){
                answer += a+(d*i);
            }
        }
        return answer;
    }
}

출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/challenges

0개의 댓글