Java script

[Java script] Test - 도넛 박스

EmilyP 2021. 4. 12. 16:38

test.html
0.00MB

5개들어가는 박스와 3개들어가는 박스에 도넛을 나눠 담을 때 최소로 몇개의 박스가 필요할까요.

 

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Document</title>

</head>

<body>

    <script type="text/javascript">

       

        function solution(n){

            five = Math.floor(n/5)

            rest = n%5

            three = Math.ceil(rest/3)

            if(rest==4){

                return five+1

            }

            else{

                return five+three

            }

        }

        console.log(solution(9))       

 

        

        

        </script>

</body>

</html>