프로그래머스(Java)/Lv0

[프로그래머스 : 코딩테스트 입문]Lv0. 피자 나눠 먹기 (1)(Java)

지미지민 2024. 3. 22. 22:05

 

 

 

💜 코드


class Solution {
    public int solution(int n) {
        if(n<=7){
            return 1;
        }else if(n%7 == 0){
            return n/7;
        }
        return n/7+1;
    }
}

 

 

 

💜 실행 결과


 

 

 

💜 다른 사람의 풀이


class Solution {
    public int solution(int n) {
        return (n + 6) / 7;
    }
}