// Arup Guha
// 7/19/05 (originally)
// Originally a solution to a programming assignment for the BHCSI,
// adapted to be a class example in COP 3330 Spring 2006 on 1/12/05.

import java.io.*;

public class prime {

  public static void main(String[] args) {

    // Keeps track of if the first value has been printed.
    boolean firstval = true; 

    // Print header.
    System.out.print("The prime numbers in between 2 and 100 are ");
 
    // Loop through all the values in the range.
    for (int tryval=2; tryval<=100; tryval++) {

      boolean prime = true;

      // Try dividing the number we are trying by all possibilities.
      // The +1 is to account for a possible rounding error.
      for (int trydiv=2; trydiv < tryval; trydiv++) {

        // If it divides evenly, the number isn't prime.
        if (tryval%trydiv == 0) {
          prime = false;
          break;
        }
      }

      // We only print something if the number is prime.
      if (prime) {

        // If it's the first number, don't precede it with a comma.
        if (firstval) {
          System.out.print(tryval);
          firstval = false;
        }

        // Otherwise, print a comma and then the value.
        else
          System.out.print(", "+tryval);
      }

    } //  end for tryval
    
    // Finish the sentence!
    System.out.println(".");

  } // end main

} // end class
