Skip to content

Instantly share code, notes, and snippets.

Created October 14, 2012 14:54
Show Gist options
  • Save anonymous/3888827 to your computer and use it in GitHub Desktop.
Save anonymous/3888827 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class exercise3 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("please enter a natural number.");
int naturalNumber = in.nextInt();
int count = 0 ;
while( naturalNumber !=1) {
if (naturalNumber%2 == 0)
int naturalNumber = new int [natualNumber/2];
count++ ;
else (naturalNumber%2 != 0)
int naturalNumber = new int [naturalNumber*3 +1];
count++ ;
}
System.out.println("The number of steps in told was " + count);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment