UVa 100 - 3n+1

Java code