Javascript Algorithms

[Javascript Algorithms]1-3 연필개수

yangjoy 2021. 7. 20. 00:11
<html>
    <head>
        <meta charset="UTF-8">
        <title>출력결과</title>
    </head>
    <body>
        <script>
            function solution(n){
                let answer=Math.ceil(n/12);
                //Math.ceil 은 소숫점이 조금이라도 있으면 올림해준다.
                //Math.floor 내림
                //Math.round 반올림
                //Math.sqrt 제곱근
                
                return answer;
            }

            // console.log(solution(25));
            //3
            console.log(solution(178));
            //15
        </script>
    </body>
</html>