this is the Question: An integer is said to be prime if it is greater than 1 and divisible only by 1 and itself. For example, 2, 3, 5 and 7 are prime, but 4, 6, 8 and 9 are not.
You're importing the script in the <head>
, so that's where it's output will go. Try moving it to the <body>
.
That's possibly the slowest way to find primes.
edit — another problem is this:
for(int i=2;i<n;i++)
There is no int
keyword in JavaScript - it's var
. That would cause a syntax error, which would show up in the error console. Neither is there a boolean
keyword (declaration of "prime"). It's important to keep the error console open while doing any HTML/JavaScript development.
This is because you are attempting to write the <textarea>
to the <head>
element. Try loading/executing your script within the <body>
.