Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package razvarov_harjutus7;
- import java.util.Scanner;
- /**
- *
- * @author AR
- */
- public class Razvarov_harjutus7_2 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- int i,n;
- Scanner scan = new Scanner(System.in);
- int a = scan.nextInt();
- int b = scan.nextInt();
- for (i=a; i<=b; i++) {
- n = i;
- System.out.printf("-> %d ", n);
- while (n != 1) {
- if (n%2 == 0)
- n = n / 2;
- else
- n = (n*3 + 1) / 2;
- System.out.printf("%d ", n);
- }
- System.out.printf("\n");
- }
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement