Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Random;
- public class awesome
- { public static Scanner input;
- public static Random r;
- public static void main ( String[] args )
- {
- input = new Scanner(System.in);
- r = new Random();
- int n;
- System.out.println("Starting number: ");
- n = input.nextInt();
- do{
- int check = n%2;
- int counter = 0;
- if(check==0){
- n = n/2;
- System.out.print(n + "\t");
- if(counter == 10){
- System.out.println();
- counter = 0;
- }
- }else{
- n = n*3+1;
- System.out.print(n + "\t");
- if(counter == 10){
- System.out.println();
- counter = 0;
- }
- counter = counter + 1;
- }
- }while(n != 1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement