Jump to content

Taxicab numbers: Difference between revisions

Added 11l
m (added a word.)
(Added 11l)
Line 32:
* [[wp:Taxicab_number|taxicab number]] on Wikipedia   (includes the story on how taxi-cab numbers came to be called).
<br><br>
 
=={{header|11l}}==
{{trans|Python}}
 
<lang 11l>V cubes = (1..1199).map(x -> Int64(x) ^ 3)
[Int64 = Int64] crev
L(x3) cubes
V x = L.index
crev[x3] = x + 1
 
V sums = sorted(multiloop_filtered(cubes, cubes, (x, y) -> y < x, (x, y) -> x + y))
 
V idx = 0
L(i) 1 .< sums.len - 1
I sums[i - 1] != sums[i] & sums[i] == sums[i + 1]
idx++
I (idx > 25 & idx < 2000) | idx > 2006
L.continue
 
V n = sums[i]
[(Int64, Int64)] p
L(x) cubes
I n - x < x
L.break
I n - x C crev
p.append((crev[x], crev[n - x]))
print(‘#4: #10’.format(idx, n), end' ‘ ’)
L(x1, x2) p
print(‘ = #4^3 + #4^3’.format(x1, x2), end' ‘ ’)
print()</lang>
 
{{out}}
<pre>
1: 1729 = 1^3 + 12^3 = 9^3 + 10^3
2: 4104 = 2^3 + 16^3 = 9^3 + 15^3
3: 13832 = 2^3 + 24^3 = 18^3 + 20^3
4: 20683 = 10^3 + 27^3 = 19^3 + 24^3
5: 32832 = 4^3 + 32^3 = 18^3 + 30^3
6: 39312 = 2^3 + 34^3 = 15^3 + 33^3
7: 40033 = 9^3 + 34^3 = 16^3 + 33^3
8: 46683 = 3^3 + 36^3 = 27^3 + 30^3
9: 64232 = 17^3 + 39^3 = 26^3 + 36^3
10: 65728 = 12^3 + 40^3 = 31^3 + 33^3
11: 110656 = 4^3 + 48^3 = 36^3 + 40^3
12: 110808 = 6^3 + 48^3 = 27^3 + 45^3
13: 134379 = 12^3 + 51^3 = 38^3 + 43^3
14: 149389 = 8^3 + 53^3 = 29^3 + 50^3
15: 165464 = 20^3 + 54^3 = 38^3 + 48^3
16: 171288 = 17^3 + 55^3 = 24^3 + 54^3
17: 195841 = 9^3 + 58^3 = 22^3 + 57^3
18: 216027 = 3^3 + 60^3 = 22^3 + 59^3
19: 216125 = 5^3 + 60^3 = 45^3 + 50^3
20: 262656 = 8^3 + 64^3 = 36^3 + 60^3
21: 314496 = 4^3 + 68^3 = 30^3 + 66^3
22: 320264 = 18^3 + 68^3 = 32^3 + 66^3
23: 327763 = 30^3 + 67^3 = 51^3 + 58^3
24: 373464 = 6^3 + 72^3 = 54^3 + 60^3
25: 402597 = 42^3 + 69^3 = 56^3 + 61^3
2000: 1671816384 = 428^3 + 1168^3 = 940^3 + 944^3
2001: 1672470592 = 29^3 + 1187^3 = 632^3 + 1124^3
2002: 1673170856 = 458^3 + 1164^3 = 828^3 + 1034^3
2003: 1675045225 = 522^3 + 1153^3 = 744^3 + 1081^3
2004: 1675958167 = 492^3 + 1159^3 = 711^3 + 1096^3
2005: 1676926719 = 63^3 + 1188^3 = 714^3 + 1095^3
2006: 1677646971 = 99^3 + 1188^3 = 891^3 + 990^3
</pre>
 
=={{header|Befunge}}==
1,481

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.