Advertisement
Guest User

Untitled

a guest
Oct 24th, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. 1. Declare and implement a class named Pythagorean. The class will contain the following five methods:
  2.  
  3. getTriples(int n) prints all Pythagorean triples (a, b, c) such that a2 + b2 = c2, 0 < a ≤ b ≤ c ≤ n.
  4.  
  5.  
  6.  
  7. getQuadruples(int n) prints all Pythagorean quadruples (a, b, c, d) such that a2 + b2 + c2 = d2, 0 < a ≤ b ≤ c ≤ d ≤ n.
  8.  
  9.  
  10.  
  11. getQuintuples(int n) prints all Pythagorean quintuples (a, b, c, d, e) such that a2 + b2 + c2 + d2 = e2, 0 < a ≤ b ≤ c ≤ d ≤ e ≤ n.
  12.  
  13.  
  14.  
  15. getHextuples(int n) prints all Pythagorean hextuples (a, b, c, d, e, f) such that a2 + b2 + c2 + d2 + e2 = f2, 0 < a ≤ b ≤ c ≤ d ≤ e ≤ f ≤ n.
  16.  
  17.  
  18.  
  19. getSeptuples(int n) prints all Pythagorean septuples (a, b, c, d, e, f, g) such that a2 + b2 + c2 + d2 + e2 + f2 = g2, 0 < a ≤ b ≤ c ≤ d ≤ e ≤ f ≤ g ≤ n.
  20.  
  21.  
  22.  
  23. For example, for n = 10. These methods will print
  24.  
  25. triples:
  26.  
  27. 3, 4, 5
  28.  
  29. 6, 8, 10
  30.  
  31.  
  32.  
  33. quadruples:
  34.  
  35. 1, 2, 2, 3
  36.  
  37. 1, 4, 8, 9
  38.  
  39. 2, 3, 6, 7
  40.  
  41. 2, 4, 4, 6
  42.  
  43. 3, 6, 6, 9
  44.  
  45. 4, 4, 7, 9
  46.  
  47.  
  48.  
  49. quintuples:
  50.  
  51. 1, 1, 1, 1, 2
  52.  
  53. 1, 1, 3, 5, 6
  54.  
  55. 1, 1, 7, 7, 10
  56.  
  57. 1, 2, 2, 4, 5
  58.  
  59. 1, 3, 3, 9, 10
  60.  
  61. 1, 4, 4, 4, 7
  62.  
  63. 1, 5, 5, 7, 10
  64.  
  65. 2, 2, 2, 2, 4
  66.  
  67. 2, 2, 3, 8, 9
  68.  
  69. 2, 2, 4, 5, 7
  70.  
  71. 2, 4, 4, 8, 10
  72.  
  73. 2, 4, 5, 6, 9
  74.  
  75. 3, 3, 3, 3, 6
  76.  
  77. 4, 4, 4, 4, 8
  78.  
  79. 5, 5, 5, 5, 10
  80.  
  81.  
  82.  
  83. hextuples:
  84.  
  85. 1, 1, 1, 2, 3, 4
  86.  
  87. 1, 1, 1, 4, 9, 10
  88.  
  89. 1, 1, 1, 5, 6, 8
  90.  
  91. 1, 1, 2, 3, 7, 8
  92.  
  93. 1, 1, 3, 3, 4, 6
  94.  
  95. 1, 1, 3, 5, 8, 10
  96.  
  97. 1, 2, 2, 2, 6, 7
  98.  
  99. 1, 2, 2, 6, 6, 9
  100.  
  101. 1, 2, 3, 5, 5, 8
  102.  
  103. 1, 3, 3, 3, 6, 8
  104.  
  105. 1, 3, 4, 5, 7, 10
  106.  
  107. 2, 2, 2, 2, 3, 5
  108.  
  109. 2, 2, 2, 4, 6, 8
  110.  
  111. 2, 2, 3, 4, 4, 7
  112.  
  113. 2, 3, 4, 4, 6, 9
  114.  
  115. 3, 3, 3, 3, 8, 10
  116.  
  117. 3, 4, 5, 5, 5, 10
  118.  
  119. 4, 4, 4, 4, 6, 10
  120.  
  121.  
  122.  
  123. septuples:
  124.  
  125. 1, 1, 1, 1, 1, 2, 3
  126.  
  127. 1, 1, 1, 1, 3, 6, 7
  128.  
  129. 1, 1, 1, 1, 4, 4, 6
  130.  
  131. 1, 1, 1, 2, 2, 5, 6
  132.  
  133. 1, 1, 1, 2, 3, 3, 5
  134.  
  135. 1, 1, 1, 2, 5, 7, 9
  136.  
  137. 1, 1, 1, 3, 4, 6, 8
  138.  
  139. 1, 1, 1, 5, 6, 6, 10
  140.  
  141. 1, 1, 2, 2, 3, 9, 10
  142.  
  143. 1, 1, 2, 3, 3, 5, 7
  144.  
  145. 1, 1, 2, 3, 6, 7, 10
  146.  
  147. 1, 1, 2, 5, 5, 5, 9
  148.  
  149. 1, 1, 3, 3, 4, 8, 10
  150.  
  151. 1, 1, 3, 3, 5, 6, 9
  152.  
  153. 1, 2, 2, 2, 2, 8, 9
  154.  
  155. 1, 2, 2, 3, 3, 3, 6
  156.  
  157. 1, 2, 3, 3, 3, 7, 9
  158.  
  159. 1, 2, 3, 3, 4, 5, 8
  160.  
  161. 1, 2, 3, 5, 5, 6, 10
  162.  
  163. 1, 3, 3, 3, 6, 6, 10
  164.  
  165. 1, 3, 3, 4, 4, 7, 10
  166.  
  167. 1, 4, 4, 4, 4, 4, 9
  168.  
  169. 2, 2, 2, 2, 2, 4, 6
  170.  
  171. 2, 2, 2, 2, 4, 7, 9
  172.  
  173. 2, 2, 2, 4, 6, 6, 10
  174.  
  175. 2, 2, 3, 3, 5, 7, 10
  176.  
  177. 2, 2, 4, 4, 4, 5, 9
  178.  
  179. 2, 3, 3, 3, 3, 3, 7
  180.  
  181. 2, 3, 3, 3, 5, 5, 9
  182.  
  183. 3, 3, 3, 3, 3, 6, 9
  184.  
  185. 3, 3, 4, 4, 5, 5, 10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement