Taxi Quotient Reversed (Math Brainteaser)

Otis

Elite Member
Joined
Apr 22, 2015
Messages
4,414
What's the taxi number? It's a 3-digit number. If you divide it by 3 and reverse the quotient's digits, then you'll get one more than the taxi number.

?

Let ABC represent the 3-digit taxi number.

The last digit of the reversed quotient must equal C+1 because "one more than the taxi number" is ABC+1.

In other words, the first digit of ABC/3 is C+1.

Long-Division Algorithm: "3 goes into A how many times?" We already know it's C+1 times.

Long-Division Algorithm: "Multiply 3 times C+1 and subtract the product from A."

A - 3(C + 1) = A - 3C - 3

The Remainder Principle says: A-3C-3 is less than the divisor.

Case I:
A-3C-3 = 1 yields A = 3C + 4

Case II:
A-3C-3 = 2 yields A = 3C + 5

A is a digit. Therefore, C = 1 and A = 7 or 8

ABC is a multiple of 3, so A+B+C must be 9, 12 or 15.

Testing possibilities: 711 FAIL, 741 SUCCESS!

The taxi number is 741.

[imath]\;[/imath]
 
Let x= the taxi number.
Then x = 100a + 10b + c
Now x/3 = 33a + 3b + (a+b+c)
(The reverse of x/3) = 100a + 10b + c + 1
????
 
Let the taxi number be abc. From the question text...
abc/3 = xyz ⇒ abc = xyz*3
abc + 1 = zyx ⇒ abc = zyx-1

Therefore xyz*3 = zyx-1 ⇒ 3*xyz + 1 = zyx

300x + 30y + 3z + 1 = 100z + 10y + x

299x + 20y + 1 = 97z

The above is a Diophantine equation with constraints 0 ≤ x,y ≤ 9 and 1 ≤ z ≤ 9

--

Try x=0
20y+1=97z NOPE since 20y≠96 and 20y≠193 and z>2 gives y>9

Try x=1
10*(2y + 30) = 97z NOPE

Try x=2
20y = 97z - 599 to generate a positive y, then 97z>599 which means z>6, and putting z=7 gives y=4 exactly (this is the only exact result for x=2)

Try x=3
20y = 97z - 898 NOPE since all possible values of z would give a negative y

Obviously x is not greater than 3 (otherwise z>9 or y>9)

--

The one possible taxi number is abc = zyx-1 = 741
 
Let the taxi number be abc. From the question text...
abc/3 = xyz ⇒ abc = xyz*3
abc + 1 = zyx ⇒ abc = zyx-1

Therefore xyz*3 = zyx-1 ⇒ 3*xyz + 1 = zyx

300x + 30y + 3z + 1 = 100z + 10y + x

299x + 20y + 1 = 97z

The above is a Diophantine equation with constraints 0 ≤ x,y ≤ 9 and 1 ≤ z ≤ 9

--

Try x=0
20y+1=97z NOPE since 20y≠96 and 20y≠193 and z>2 gives y>9

Try x=1
10*(2y + 30) = 97z NOPE

Try x=2
20y = 97z - 599 to generate a positive y, then 97z>599 which means z>6, and putting z=7 gives y=4 exactly (this is the only exact result for x=2)

Try x=3
20y = 97z - 898 NOPE since all possible values of z would give a negative y

Obviously x is not greater than 3 (otherwise z>9 or y>9)

--

The one possible taxi number is abc = zyx-1 = 741
Nice!

⭐

[imath]\;[/imath]
 
For anyone interested in a bonus question:

What's the next number having the same property? (It has more than 3 digits.)

[imath]\;[/imath]
 
What's the next number having the same property? (It has more than 3 digits.)
That took awhile: 7425741

I gave up and wrote some lazycode (using a macro language). I just updated it each time the test values gained another digit -- but the execution was sloooow because I can't figure out how to prevent the host software from printing every variable assignment. :rolleyes:

Code:
for n from 1000002 by 3 while n<10000000 do
  a:=trunc(n/3000000);
  b:=trunc(n/300000-10*a);
  c:=trunc(n/30000-100*a-10*b);
  d:=trunc(n/3000-1000*a-100*b-10*c);
  e:=trunc(n/300-10000*a-1000*b-100*c-10*d);
  f:=trunc(n/30-100000*a-10000*b-1000*c-100*d-10*e);
  g:=n/3-1000000*a-100000*b-10000*c-1000*d-100*e-10*f;
  if n=1000000*g+100000*f+10000*e+1000*d+100*c+10*b+a-1 then
    print(n);
    n:=10000000;
  fi;
od;

[imath]\;[/imath]
 
Fairly literal translation of the above code in to Python...
Python:
for n in range(1000002, 10000000, 3):
  a = n//3000000 # the operator "//" provides integer divide in python
  b = n//300000 -   10*a
  c = n//30000 -   100*a -     10*b
  d = n//3000 -   1000*a -    100*b -    10*c
  e = n//300 -   10000*a -   1000*b -   100*c -   10*d
  f = n//30 -   100000*a -  10000*b -  1000*c -  100*d -  10*e
  g = n//3 -   1000000*a - 100000*b - 10000*c - 1000*d - 100*e - 10*f
 
  if n == 1000000*g + 100000*f + 10000*e + 1000*d + 100*c + 10*b + a - 1:
    print(n)
    break

EDIT: I wonder what the next higher number is :)
 
Last edited:
OK I know I am late on this one, but I have been traveling.

[math]\text {Given: all letters are decimal digits};\\ 100p + 10q + r < 1000;\\ \dfrac{100p + 10q + r}{3} = 100u + 10v + w;\\ 100w + 10v + u = 100p + 10q + r + 1;\\ \text {and } p > 0.\\ \text {Find } 100p + 10v + r.[/math]
[math]\therefore 100p + 10q + r = 300u + 30v + 3w.\\ u > 3 \implies 100p + 10q + r \ge 1200, \text {impossible.}\\ \therefore 0 \le u \le 3.[/math]
[math]100w + 10v + u = 100p + 10q + r + 1 = 300u + 30v + 3w + 1 \implies\\ 20v = 100w - 300u - (3w + 1 - u).\\ 0 \le w \le 9 \implies 1 \le 3w + 1 \le 28.\\ 0 \le u \le 3 \implies - 2 \le 3w + 1 - u \le 28.\\ v = \dfrac{100w - 300u - (3w + 1 - u)}{20} = 5w - 15u - \dfrac{3w + 1 - u}{20}.\\ \text {But } v \in \mathbb Z \implies \dfrac{3w + 1 - u}{20} \in \mathbb Z \implies\\ 3w + 1 - u = 0 \text { or } 20 \implies w = \dfrac{u - 1}{3} \text { or } \dfrac{u + 19}{3}\\ \text {But } w \in \mathbb Z \text { and } 0 \le u \le 3 \implies\\ w = 0 \text { or } w = 7.\\ w = 0 \implies u = 1 \implies v = 0 - 15 - 0, \text { impossible because } v \ge 0.\\ \therefore w = 7 \implies u = 2 \implies v = 5*7 - 15*2 - \dfrac{3*7 + 1 - 2}{20} = 4.\\ \therefore 100w + 10v + u = 742 \implies 100p + 10q + r = 742 - 1 = 741.[/math]

[math]\dfrac{741}{3} = 247.\\ 741 + 1 = 742 \checkmark[/math]
 
I spent a couple of days looking into this, and have found these interesting conjectures about taxi numbers (I'm pretty sure they are correct)
- there's an infinite number of them
- they all have an odd number of digits
- there's two digits that they never contain
- the centre digit is always one of two values

I've also found a method that can find them very quickly. How many 99 digit taxi numbers are there?
299426

Here's the python code that finds these taxi numbers very quickly...
Python:
def findTaxiMid(i, n):
    d=len(n)

    lookup={ "1683" : ["27"],
             "2137" : ["68"],
             "2557" : ["72"],
             "3721" : ["44","86"],
             "4274" : ["13","55"],
             "5725" : ["44","86"],
             "6278" : ["13","55"],
             "7442" : ["27"],
             "7862" : ["31"],
             "8316" : ["72"] }

    rv=0
    s = lookup.get( n[i]+n[i+1] + n[d-i-2]+n[d-i-1], [] )
    if i*2+4 == d-1:
        for mid in s:
            if mid[0] == mid[1]:
                n[i+2] = mid[0]
                nn=int("".join(n)) # as a number rather than a list of digits
                # Check that nn is a valid taxi number
                r=n[::-1] # reversed list
                nr=int("".join(r))
                if (nr + 10**(d-1))*3 == nn:
                    print(" ", nn) # Show a taxi number
                    rv += 1
                else:
                    print("Does this ever happen?")
                    exit(0)
    else:
        for mid in s:
            n[i+2] = mid[0]
            n[d-i-3] = mid[1]
            rv += findTaxiMid(i+1, n) # recursion
    return rv

def findTaxi(digits):
    print()
    count=0
    if digits%2==0: return
    elif digits==3:
        print(" ","741") # Special case taxi number
        count=1
    elif digits>5:
        # Two possible start and end digit sequences
        count=findTaxiMid(1, list("742" + ("." * (digits-6)) + "741"))
        count+=findTaxiMid(1, list("783" + ("." * (digits-6)) + "161"))
    if count>0:
        print("...there are",count,"taxi numbers with",digits,"digits")

maxDigits=25
for digits in range(3, maxDigits+1, 2):
    findTaxi(digits)
Code:
  741
...there are 1 taxi numbers with 3 digits


  7425741
...there are 1 taxi numbers with 7 digits

  783742161
...there are 1 taxi numbers with 9 digits

  74257425741
...there are 1 taxi numbers with 11 digits

  7421625783741
  7837425742161
...there are 2 taxi numbers with 13 digits

  742574257425741
  783783742162161
...there are 2 taxi numbers with 15 digits

  74216257425783741
  74257837421625741
  78374257425742161
...there are 3 taxi numbers with 17 digits

  7421621625783783741
  7425742574257425741
  7837421625783742161
  7837837425742162161
...there are 4 taxi numbers with 19 digits

  742162574257425783741
  742574216257837425741
  742578374257421625741
  783742574257425742161
  783783783742162162161
...there are 5 taxi numbers with 21 digits

  74216216257425783783741
  74216257837421625783741
  74257425742574257425741
  74257837837421621625741
  78374216257425783742161
  78374257837421625742161
  78378374257425742162161
...there are 7 taxi numbers with 23 digits

  7421621621625783783783741
  7421625742574257425783741
  7425742162574257837425741
  7425742578374216257425741
  7425783742574257421625741
  7837421621625783783742161
  7837425742574257425742161
  7837837421625783742162161
  7837837837425742162162161
...there are 9 taxi numbers with 25 digits

If a taxi number is made from the digits ".. fed ... cba .." (where "..." is a number of unknown digits and ".." is a potentially different number of unknown digits), then from the definition of a taxi number...
( .. abc ... def .. + 10^(#digits-1) ) * 3 = .. fed ... cba ..
( .. abc ... def .. + 10 000 000 000 00 ) * 3 = .. fed ... cba ..
( .. abc ... def .. + the same length number with a leftmost "1" ) * 3 = .. fed ... cba ..

What are the possible values of (fed, cba) when they are:-
1. both at the outside ends of the taxi number?
2. somewhere in the middle of the taxi number (but both at the same distance from the ends)?

It turns out that...
I wrote some simple code that goes through all possible combinations, and the only valid values for ".. fed ... cba .." are:-

1. at the outside ends
Code:
fed  cba
========
742  741
783  161
2. somewhere in the middle
Code:
fed  cba
========
000  000 Can't occur within the number otherwise all digits would be 0
999  999 Can't occur within the number otherwise all digits would be 9

162  783
216  837
257  257
374  421
378  621
421  374
425  574
574  425
578  625
621  378
625  578
742  742
783  162
837  216
 
Top