Edit : Mathematica har en algo kallas Table kanske det kan vara till hjälp?
Kod:
Table[i^2 + j^2, {i, 10}, {j, 10}]
{2, 5, 10, 17, 26, 37, 50, 65, 82, 101}, {5, 8, 13, 20, 29, 40, 53,
68, 85, 104}, {10, 13, 18, 25, 34, 45, 58, 73, 90, 109}, {17, 20,
25, 32, 41, 52, 65, 80, 97, 116}, {26, 29, 34, 41, 50, 61, 74, 89,
106, 125}, {37, 40, 45, 52, 61, 72, 85, 100, 117, 136}, {50, 53, 58,
65, 74, 85, 98, 113, 130, 149}, {65, 68, 73, 80, 89, 100, 113, 128,
145, 164}, {82, 85, 90, 97, 106, 117, 130, 145, 162, 181}, {101,
104, 109, 116, 125, 136, 149, 164, 181, 200}}
Kod:
Table[i^2 + j^2, {i, 0, 15}, {j, 0, 15}
{{0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196,
225}, {1, 2, 5, 10, 17, 26, 37, 50, 65, 82, 101, 122, 145, 170, 197,
226}, {4, 5, 8, 13, 20, 29, 40, 53, 68, 85, 104, 125, 148, 173,
200, 229}, {9, 10, 13, 18, 25, 34, 45, 58, 73, 90, 109, 130, 153,
178, 205, 234}, {16, 17, 20, 25, 32, 41, 52, 65, 80, 97, 116, 137,
160, 185, 212, 241}, {25, 26, 29, 34, 41, 50, 61, 74, 89, 106, 125,
146, 169, 194, 221, 250}, {36, 37, 40, 45, 52, 61, 72, 85, 100, 117,
136, 157, 180, 205, 232, 261}, {49, 50, 53, 58, 65, 74, 85, 98,
113, 130, 149, 170, 193, 218, 245, 274}, {64, 65, 68, 73, 80, 89,
100, 113, 128, 145, 164, 185, 208, 233, 260, 289}, {81, 82, 85, 90,
97, 106, 117, 130, 145, 162, 181, 202, 225, 250, 277, 306}, {100,
101, 104, 109, 116, 125, 136, 149, 164, 181, 200, 221, 244, 269,
296, 325}, {121, 122, 125, 130, 137, 146, 157, 170, 185, 202, 221,
242, 265, 290, 317, 346}, {144, 145, 148, 153, 160, 169, 180, 193,
208, 225, 244, 265, 288, 313, 340, 369}, {169, 170, 173, 178, 185,
194, 205, 218, 233, 250, 269, 290, 313, 338, 365, 394}, {196, 197,
200, 205, 212, 221, 232, 245, 260, 277, 296, 317, 340, 365, 392,
421}, {225, 226, 229, 234, 241, 250, 261, 274, 289, 306, 325, 346,
369, 394, 421, 450}}]
Här kan vi läsa av att 365=13^2+14^2 frågan är finns det bättre metod än bara rada upp summorna och leta efter summor som fungerar?