Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Java19 {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out.println("Enter number in range of 10 - 99:");
- int num = sc.nextInt();
- while (num < 10 || num > 99) {
- System.out.println("Enter valid number in the range of 10 - 99!");
- num = sc.nextInt();
- }
- int i = num;
- while (i > 1) {
- if (i % 2 == 0) {
- i *= 0.5;
- System.out.print(i + " ");
- }
- if (i == 1) {
- break;
- }
- if (i % 2 != 0) {
- i = (i * 3) + 1;
- System.out.print(i + " ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement