Ramanujan's Taxi Cab Numbers : A Solution

Page under construction

Here's one solution to the Taxi Cab function:

      ∇R←TaxiCab N;⎕IO;vals;sumCubes;cubes
[1]   ⎕IO←1
[2]   vals←⍳N
[3]   sumCubes←(vals∘.<vals)×cubes∘.+cubes←vals*3
[4]   R←(R=1⌽R)/R←R[⍋R←(,sumCubes)~0]
[5]   R←⍉R,[0.5](,¨(R⍷¨⊂sumCubes)×⊂vals∘.,vals)~¨⊂⊂0 0

For example:

      TaxiCab 30
  1729  1 12  9 10
  4104  2 16  9 15
 13832  2 24  18 20
 20683  10 27  19 24

The output shows the taxi cab number followed by the pairs of terms. For example 1729 = 13 + 123 = 93 + 103

An explanation of the APL code

Blah : Under construction

Other investigations concerning 1729

First we define a handy function to break a number up into its digits:

      ∇R←base Digits val
[1]  ⍝ Returns individual digits of 'val' when expressed in base 'base',
[2]  ⍝ e.g. 10 Digits 1729 gives 1 7 2 9
[3]   R←((1+⌊base⍟val+0=val)⍴base)⊤val

(a) Now to find out which numbers are evenly divisible by the sum of their digits. Here's a test of the range 1720-1770

      (0=(+/¨10 Digits¨ X)|X)/X←1719+⍳50 
1725 1728 1729 1740 1744 1746 1764 1770

(b) Now we investigate which of the first 100000 numbers behave in the same way as 1729, i.e.

      (vals=sums×10⊥¨⌽¨10 Digits¨sums←+/¨10 Digits¨ vals)/vals←⍳100000
1 81 1458 1729

In fact these are the only four natural numbers which have this property.

<< The task


CategoryPuzzles