Taxicab numbers: Difference between revisions

no edit summary
No edit summary
Line 2,872:
1677646971 ((891 990) (99 1188))
</pre>
 
=={{header|PureBasic}}==
<lang PureBasic>DisableDebugger
#MAX=1189
 
Macro q3(a,b)
a*a*a+b*b*b
EndMacro
 
Structure Cap
x.i
y.i
s.i
EndStructure
 
NewList Taxi.Cap()
 
For i=1 To #MAX
For j=i To #MAX
AddElement(Taxi()) : Taxi()\s=q3(i,j) : Taxi()\x=i : Taxi()\y=j
Next j
Next i
 
SortStructuredList(Taxi(),#PB_Sort_Ascending,OffsetOf(Cap\s),TypeOf(Cap\s))
 
If OpenConsole()
ForEach Taxi()
If sum=Taxi()\s
r$+"="+RSet(Str(Taxi()\x),4)+"³ +"+RSet(Str(Taxi()\y),4)+"³ " : Continue
EndIf
If CountString(r$,"=")>=2 : c+1 : EndIf
If CountString(r$,"=")=2
Select c
Case 1 To 25, 2000 To 2006 : PrintN(RSet(Str(c),5)+": "+RSet(Str(sum),10)+r$)
Case Bool(c>2006) : Break
EndSelect
EndIf
r$=""
sum=Taxi()\s : r$="="+RSet(Str(Taxi()\x),4)+"³ +"+RSet(Str(Taxi()\y),4)+"³ "
Next
PrintN("FIN.") : Input()
EndIf</lang>{{out}}
<pre> 1: 1729= 1³ + 12³ = 9³ + 10³
2: 4104= 2³ + 16³ = 9³ + 15³
3: 13832= 2³ + 24³ = 18³ + 20³
4: 20683= 10³ + 27³ = 19³ + 24³
5: 32832= 4³ + 32³ = 18³ + 30³
6: 39312= 2³ + 34³ = 15³ + 33³
7: 40033= 9³ + 34³ = 16³ + 33³
8: 46683= 3³ + 36³ = 27³ + 30³
9: 64232= 17³ + 39³ = 26³ + 36³
10: 65728= 12³ + 40³ = 31³ + 33³
11: 110656= 4³ + 48³ = 36³ + 40³
12: 110808= 6³ + 48³ = 27³ + 45³
13: 134379= 12³ + 51³ = 38³ + 43³
14: 149389= 8³ + 53³ = 29³ + 50³
15: 165464= 20³ + 54³ = 38³ + 48³
16: 171288= 17³ + 55³ = 24³ + 54³
17: 195841= 9³ + 58³ = 22³ + 57³
18: 216027= 3³ + 60³ = 22³ + 59³
19: 216125= 5³ + 60³ = 45³ + 50³
20: 262656= 8³ + 64³ = 36³ + 60³
21: 314496= 4³ + 68³ = 30³ + 66³
22: 320264= 18³ + 68³ = 32³ + 66³
23: 327763= 30³ + 67³ = 51³ + 58³
24: 373464= 6³ + 72³ = 54³ + 60³
25: 402597= 42³ + 69³ = 56³ + 61³
2000: 1671816384= 428³ +1168³ = 940³ + 944³
2001: 1672470592= 29³ +1187³ = 632³ +1124³
2002: 1673170856= 458³ +1164³ = 828³ +1034³
2003: 1675045225= 522³ +1153³ = 744³ +1081³
2004: 1675958167= 492³ +1159³ = 711³ +1096³
2005: 1676926719= 63³ +1188³ = 714³ +1095³
2006: 1677646971= 99³ +1188³ = 891³ + 990³
FIN.</pre>
 
=={{header|Python}}==
164

edits