Created
October 14, 2012 14:54
-
-
Save anonymous/3888827 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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