All pastes #386017 Raw Edit

Miscellany

public java v1 · immutable
·published 2007-03-08 08:28 UTC
rendered paste body
// Author: Mark Jessop ( lenniethelemming@gmail.com )// Purpose: Iterate Syracuse numberspublic class Syracuse{	public static void main (String[] args)	{	    int x = 19;// Define Syracuse number here		System.out.println("The first number is " + x);				while (x > 1) // Start the loop. Loop will end when x = 1		{		    if (x % 2 == 0)  // Check if the number is even.		    {			x=x/2; // If it is, divide it by two.		    }		else		    {			x = (3 * x) + 1; // If it isn't, times it by 3 and add 1		    }		    System.out.println("The new syracuse number is " + x); // Print the current number		}		System.out.println("Syracuse number is now 1. Loop ended."); // Loop ended	}}