I'm trying to display prime numbers from 1-999 in a table and I just can't find a simple answer online or anywhere else.
Here's the question from the book:
A prime number is a number than can only be divided by itself or by one. Examples of prime numbers include 1, 3, 5, 13, and 17. Write a script that prints the prime numbers between 1 and 999 in a table that consists of 10 columns. You will need to use several looping and conditional statements to test all division possibilities. Use document.write() statements to create the table elements and a counter variable to create the table so that it consists of 10 columns. The counter variable should start with an initial value of 0 and be incremented by one each time your code identifies a prime number and prints it in a table cell. Once the counter variable reaches a value of 10 (meaning that 10 cells have been added to the current row), print
</tr><tr>
to start a new row and reset the variable to 0. Save the document as PrimeNumbers.html.
Any help is greatly appreciated! I am really stuck on this one.