08_ for 練習 _ sumOf7

  • <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8" />
            <title>Sum of Odd/Even</title>
        </head>
        <body>
            <script type="text/javascript">
                var sumSeven = 0;
                var count = 0;
                var i;
                
                for(i=1; i<=100; i++)
                {
                    if(i%7 == 0)
                    {
                        sumSeven += i;
                        count++;
                    }
                }
                document.write("The sum of seven during 1~100 is "+sumSeven+"<br />");
                document.write("Count "+count+"<br />");
            </script>
        </body>
    </html>
相關文章
相關標籤/搜索