Advertisement
marking2112

asdasfagfadsfadsad

Jul 24th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.97 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Demo {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int n = Integer.parseInt(scanner.nextLine());
  8.  
  9.         int copyNum = n;
  10.         int num3 = copyNum % 10;
  11.         copyNum /= 10;
  12.         int num2 = copyNum % 10;
  13.         copyNum /= 10;
  14.         int num1 = copyNum % 10;
  15.  
  16.         int finalNum = n;
  17.  
  18.         for (int i = 1; i <= num1 + num2; i++) {
  19.             for (int j = 1; j <= num1 + num3; j++) {
  20.                 if (n % 5 == 0){
  21.                     finalNum -= num1;
  22.                     System.out.printf("%d ", finalNum);
  23.                 }else if (n % 3 == 0){
  24.                     finalNum -= num2;
  25.                     System.out.printf("%d ", finalNum);
  26.                 } else {
  27.                     finalNum += num3;
  28.                     System.out.printf("%d ", finalNum);
  29.                 }
  30.  
  31.             }
  32.             System.out.println();
  33.         }
  34.  
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement