Note that there are some explanatory texts on larger screens.

plurals
  1. POProgram to display the first 100 prime numbers is not displaying
    primarykey
    data
    text
    <p>I am new to Java and I have been searching for an answer around the internet for a good hour but could not find anything.</p> <p>I'm trying to create a program that displays the first 100 prime numbers in this format: </p> <pre><code>First One Hundred Primes: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293 307 311 313 317 331 337 347 349 353 359 367 373 379 383 389 397 401 409 419 421 431 433 439 443 449 457 461 463 467 479 487 491 499 503 509 521 523 541 </code></pre> <p>EDIT: ^ This format is supposed to be right-justified as well.</p> <p>I'm not sure why it's not displaying anything when I try to run it in the console. And no, my code is not completely finished. Please help me on why it's not displaying and anything else I've done wrong, thanks! :)</p> <p>This is my code right now:</p> <pre><code>public class PrimeNumbers { public static void main(String[] args) { final int DIVISOR = 1; boolean isPrime; int test1 = 0; int test2 = 0; int num = 1; int count = 0; while(count &lt; 101) { test1 = num/DIVISOR; //divides number by 1 test2 = num%num; //gets remainder of number if (test1 == num &amp;&amp; test2 == 0 &amp;&amp; num &gt; 1) //checks if test 1 is the same as num, test2 equals to 0 and if num is greater than 1 isPrime = true; else isPrime = false; if (isPrime == true) { System.out.format("%3.3f"); System.out.println("First One Hundred Primes:"); System.out.print(num); } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload