why won't this run???

new to java, can't get this shit to work.


/* CS7 - Summer 2003
* Ben Bucher
*
* Description:
* This program generates hailstone sequences, and determines how
* many elements were in the sequence as well as the largest element
* seen. Sequences are formed by repeatedly dividing numbers by 2
* when even, and tripling and adding 1 when odd.
*/

public class hail
{



public static void main(String[] args)
{
int startval; //variable assignments
int current;
int max;
int count;

System.out.println("Welcome to the Hailstone generator.
");
for(startval=1; startval<=6; startval++)
{
current = startval*13;

System.out.println("Running Hailstone series for "+ current);


count=1; // initializes count to one
max=current; //max may be first number

while((current!=4)||(current!=2)||(current!=1))
{

if (current%2==1)
current = 3 * current + 1;
else
current = current / 2; // if even, divide by 2

if (current > max)
max = current;

count = count + 1;
}

System.out.println("You had "+ count+ " elements in that sequence."); //pr$
System.out.println("The maximum was "+ max);
}
}
}



Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories