Search code examples
javascriptfactorial

"Unexpected end of input" in javascript program


<html>
<head>
<title>
</title>

<script>
var n = 2;
var days = 365;

function factorial() {
        var result = 1;
        for (var i = 1; i <= n; i++) {
            result *= i
      }
       return result;
    }  

var theNumber = function baseExponent (base, exponent) {
    var number = 1;
    for (i=0; i < exponent; i++) {
        var number = base * number;
    }
    return number
}


document.write(factorial()*182)/(theNumber(days, n)
//i used the (formula n! * combination 365 2)/365^n
//i cheated a bit and just did the math for parts of this specific problem
</script>
</head>
<body>




</body>
</html>

i am getting an "Uncaught syntax error: unexpected end of input" for my tag and I can't figure out why. Any ideas?


Solution

  • Your "document.write" line has an unmatched open paren.