Advertisement
Guest User

Untitled

a guest
Nov 29th, 2015
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3. import java.util.Random;
  4.  
  5. public class awesome
  6. { public static Scanner input;
  7. public static Random r;
  8. public static void main ( String[] args )
  9. {
  10. input = new Scanner(System.in);
  11. r = new Random();
  12. int n;
  13. System.out.println("Starting number: ");
  14. n = input.nextInt();
  15. do{
  16. int check = n%2;
  17. int counter = 0;
  18. if(check==0){
  19. n = n/2;
  20. System.out.print(n + "\t");
  21. if(counter == 10){
  22. System.out.println();
  23. counter = 0;
  24. }
  25. }else{
  26. n = n*3+1;
  27. System.out.print(n + "\t");
  28. if(counter == 10){
  29. System.out.println();
  30. counter = 0;
  31. }
  32. counter = counter + 1;
  33. }
  34.  
  35.  
  36. }while(n != 1);
  37.  
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement