Taxicab numbers: Difference between revisions

m
→‎{{header|Pascal}}: change to <lang pascal> for sysntax highlightning
(inserted Pascal)
m (→‎{{header|Pascal}}: change to <lang pascal> for sysntax highlightning)
Line 1,331:
{{works with |Free Pascal}}
searchSameSum takes most of the time.[[c]] Version is ~9 times faster aka 43 ms.
<lang pascal>program taxiCabNo;
uses
sysutils;
Line 1,472:
real 0m0.383s
</pre>
pre> 1 1729 = 12^3 + 1^3 = 10^3 + 9^3
2 4104 = 16^3 + 2^3 = 15^3 + 9^3
.....
24 373464 = 72^3 + 6^3 = 60^3 + 54^3
25 402597 = 69^3 + 42^3 = 61^3 + 56^3
2000 1671816384 = 1168^3 + 428^3 = 944^3 + 940^3
2001 1672470592 = 1187^3 + 29^3 = 1124^3 + 632^3
..
2005 1676926719 = 1188^3 + 63^3 = 1095^3 + 714^3
2006 1677646971 = 1188^3 + 99^3 = 990^3 + 891^3
count of solutions 2297
maximal insertion distance 50
 
real 0m0.383s
 
=={{header|Perl}}==
Uses segmentation so memory use is constrained as high values are searched for. Also has parameter to look for Ta(3) and Ta(4) numbers (which is when segmentation is really needed). By default shows the first 25 numbers; with one argument shows that many; with two arguments shows results in the range.
Anonymous user