galinyotsev123

ProgBasicsJavaBook7.2ComplexLoop02magicCombination2

Jan 11th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class E02magicCombination {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int magic = Integer.parseInt(scanner.nextLine());
  8.  
  9. int d1 = 0;
  10. int d2;
  11. int d3;
  12. int d4;
  13. int d5;
  14. int d6;
  15.  
  16.  
  17. while (d1 <= 9) {
  18. d2 = 0;
  19. d1++;
  20.  
  21. while (d2 <= 9) {
  22. d3 = 0;
  23. d2++;
  24.  
  25. while (d3 <= 9) {
  26. d4 = 0;
  27. d3++;
  28.  
  29. while (d4 <= 9) {
  30. d5 = 0;
  31. d4++;
  32.  
  33. while (d5 <= 9) {
  34. d6 = 0;
  35. d5++;
  36.  
  37. while (d6 <= 9) {
  38. d6++;
  39.  
  40.  
  41. if (d1 * d2 * d3 * d4 * d5 * d6 == magic) {
  42. System.out.print(String.format("%d%d%d%d%d%d ", d1, d2, d3, d4, d5, d6));
  43. }
  44.  
  45. }
  46.  
  47. }
  48. }
  49. }
  50. }
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment