
-----------------------------------
HeavenAgain
Mon Mar 05, 2007 10:23 pm

Nim Game and Goldbach's Conjecture
-----------------------------------
well, i programed 2 simple program today, one is the Goldbach's Conjecture and another is the Nim game; where there are 4 piles, each pile contains 4 - 8 sticks, and you take an amout of sticks from one pile only, taking turns, the one who takes the last stick loses! (note, this game is for two players only, i havent build a computer player yet)

Goldbach

import java.io.*;
class GCassignment
{
  public static int nextNumber()throws Exception
  {
    BufferedReader in = new BufferedReader (new InputStreamReader(System.in));
    int number;
    do
    {
      System.out.println("Please enter an even integer greater than 2...Enter 0 to stop.");
      number = Integer.parseInt(in.readLine());
      if (number == 0)
        System.out.println("Exiting program");
      else if (number < 2)
        System.out.println("Must be greater than 2! Please enter again.");
      else if (number % 2 != 0)
        System.out.println("Not an even number! Please enter again.");
      else
        ;
    }
    while (number < 0 || number % 2 == 1 || number == 2);
    return number;
  }
  public static boolean IsPrime(int a)
  {
    boolean check = true;
    for (int i = 2 ; i != (a/2)+1 ; i++)
    {
      if (a%i == 0)
        check = false;
    }
    return check;
  }
  public static void testGoldbach(int number)
  {
    int firstnumber,secondnumber, counter = 0;
    firstnumber=2;
    boolean done = false;
    System.out.println("Generated prime number pairs:");
    System.out.println("\n     First Number     Second Number");
    while (!done)
    {
      if (firstnumber =1 )
    {
      System.out.println("\n\nThere are " + counter + " prime number combinations.");
      System.out.println("The Goldbach conjecture has been proven to be true.");
    }
    else
    {
      System.out.println("No prime number combinations generated.");
      System.out.println("The Goldbach conjecture has been proven to be false.");
    }
  }
  public static int nextPrime(int b)
  {
    int value = b;
    if (b == 2)
      value = 3;
    else
    {
      do
      {
        value += 2;
      } while (!IsPrime(value));
    }
    return value;
  }
  public static void main (String

Nim

import java.io.*;
import javax.swing.*;
class Nim
{
  public static void main (String 
