Taxicab numbers: Difference between revisions
Content added Content deleted
m (→{{header|Go}}: User new and more efficient strings.Builder, remove timings) |
(Added Befunge example.) |
||
Line 31: | Line 31: | ||
* [https://en.wikipedia.org/wiki/Taxicab_number taxicab number] on Wikipedia. |
* [https://en.wikipedia.org/wiki/Taxicab_number taxicab number] on Wikipedia. |
||
<br><br> |
<br><br> |
||
=={{header|Befunge}}== |
|||
This is quite slow in most interpreters, although a decent compiler should allow it to complete in a matter of seconds. Regardless of the speed, though, the range in a standard Befunge-93 implementation is limited to the first 64 numbers in the series, after which the 8-bit memory cells will overflow. That range could be extended in Befunge-98, but realistically you're not likely to wait that long for the results. |
|||
<lang befunge>v+1$$<_v#!`**::+1g42$$_v#<!`**::+1g43\g43::<<v,,.g42,< |
|||
>004p:0>1+24p:24g\:24g>>1+:34p::**24g::**+-|p>9,,,14v, |
|||
,,,"^3 + ^3= ^3 + ^3".\,,,9"= ".:\_v#g40g43<^v,,,,.g<^ |
|||
5+,$$$\1+:38*`#@_\::"~"1+:24p34p0\0>14p24g04^>,04g.,,5</lang> |
|||
{{out}} |
|||
<pre>1729 = 10 ^3 + 9 ^3 = 12 ^3 + 1 ^3 |
|||
4104 = 15 ^3 + 9 ^3 = 16 ^3 + 2 ^3 |
|||
13832 = 20 ^3 + 18 ^3 = 24 ^3 + 2 ^3 |
|||
20683 = 24 ^3 + 19 ^3 = 27 ^3 + 10 ^3 |
|||
32832 = 30 ^3 + 18 ^3 = 32 ^3 + 4 ^3 |
|||
39312 = 33 ^3 + 15 ^3 = 34 ^3 + 2 ^3 |
|||
40033 = 33 ^3 + 16 ^3 = 34 ^3 + 9 ^3 |
|||
46683 = 30 ^3 + 27 ^3 = 36 ^3 + 3 ^3 |
|||
64232 = 36 ^3 + 26 ^3 = 39 ^3 + 17 ^3 |
|||
65728 = 33 ^3 + 31 ^3 = 40 ^3 + 12 ^3 |
|||
110656 = 40 ^3 + 36 ^3 = 48 ^3 + 4 ^3 |
|||
110808 = 45 ^3 + 27 ^3 = 48 ^3 + 6 ^3 |
|||
134379 = 43 ^3 + 38 ^3 = 51 ^3 + 12 ^3 |
|||
149389 = 50 ^3 + 29 ^3 = 53 ^3 + 8 ^3 |
|||
165464 = 48 ^3 + 38 ^3 = 54 ^3 + 20 ^3 |
|||
171288 = 54 ^3 + 24 ^3 = 55 ^3 + 17 ^3 |
|||
195841 = 57 ^3 + 22 ^3 = 58 ^3 + 9 ^3 |
|||
216027 = 59 ^3 + 22 ^3 = 60 ^3 + 3 ^3 |
|||
216125 = 50 ^3 + 45 ^3 = 60 ^3 + 5 ^3 |
|||
262656 = 60 ^3 + 36 ^3 = 64 ^3 + 8 ^3 |
|||
314496 = 66 ^3 + 30 ^3 = 68 ^3 + 4 ^3 |
|||
320264 = 66 ^3 + 32 ^3 = 68 ^3 + 18 ^3 |
|||
327763 = 58 ^3 + 51 ^3 = 67 ^3 + 30 ^3 |
|||
373464 = 60 ^3 + 54 ^3 = 72 ^3 + 6 ^3 |
|||
402597 = 61 ^3 + 56 ^3 = 69 ^3 + 42 ^3</pre> |
|||
=={{header|C}}== |
=={{header|C}}== |