Advertisement
veronikaaa86

05. Special Numbers

Feb 13th, 2022
413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. package NestedLoops;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P05SpecialNumbers {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. int n = Integer.parseInt(scanner.nextLine());
  10.  
  11. for (int i = 1; i <= 9; i++) {
  12. for (int j = 1; j <= 9; j++) {
  13. for (int k = 1; k <= 9; k++) {
  14. for (int l = 1; l <= 9; l++) {
  15. boolean isSpecial = (n % i == 0)
  16. && (n % j == 0)
  17. && (n % k == 0)
  18. && (n % l == 0);
  19.  
  20. if (isSpecial) {
  21. System.out.printf("%d%d%d%d ", i, j, k, l);
  22. }
  23. }
  24. }
  25. }
  26. }
  27.  
  28. }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement