When Waldo recently did a conversion of a positive integral Celsius temperature c=275 to its Fahrenheit...
arithmetic/digits/rotate.temperature New
New entry, edited from material collected for the archive and not yet in a released version.
Problem
When Waldo recently did a conversion of a positive integral Celsius temperature c=275 to its Fahrenheit equivalent f (which turned out to be 527), he noticed to his amazement that he could have simply moved the last digit of c to the front to obtain f. Doing some intense calculations he failed to discover the next largest such example. Does one exist, and if so, what is it? -- Chris Long <clong@cnj.digex.net>, July 1994
Show solution
This has been answered, but no one gave the (easy) proof that all such
temperatures have been described.
First, notice that for the Fahrenheit temperature to be an integer, the
Celsius temperature must be divisible by 5, so the units digit must be
5. Suppose we are dealing with N+1-digit numbers. Then there is an
N-digit number A such that the Celsius temperature is 10A+5 and the
Fahrenheit temperature is 5x10^N + A. So the conversion equation
9C+160=5F gives us 17A + 41 = 5x10^N. Modulo 17, this requires
5x10^N==41==7; multiplying both sides by 7 gives
10^N==35x10^N==49==-2. Clearly this holds for N=2; Fermat's little
theorem shows that this holds for N=16K+2, and since it doesn't hold
for N=8+2 that is all the solutions there can be.
So the Celsius temperature is
5+10x(5x10^(16K+2)-41)/17 = (5x10^(16K+3)-325)/17
and the Fahrenheit temperature is
5x10^(16K+2) + (5x10^(16K+2)-41)/17 = (9x10^(16K+3)-41)/17.
................
It's no coincidence that the solutions [5]294117647058823527[5]
................
are so reminiscent of 5/17 = 0.2941176470588235 and
................
9/17 = 0.5294117647058823.
If Waldo were to convert Celsius to Fahrenheit by moving the _first_
digit to the _end_, the situation is a little trickier, since he could
not immediately deduce the identity of the digit. If the Celsius
temperature is Dx10^N + A and the Fahrenheit is 10A+D, then
9(Dx10^N + A)+160 = 5(10A+D), so (9x10^N - 5)D=41A-160, so we need to
find solutions of (9x10^N - 5)D==-160 (mod 41). Since 10^5==1(mod 41),
we need only consider N (mod 5). We want (9x10^N - 5)D==-160==4;
multiplying both sides by -10 gives -10(9x10^N - 5)D==-40==1. The
following table shows the work (mod 41):
N(mod 5) 0 1 2 3 4
10^N 1 10 18 16 -4
9x10^N 9 8 -2 21 5
9x10^N-5 4 3 -7 16 0
-10(9x10^N-5) 1 11 -12 4 0
D 1 15 17 -10 NaR (Not a Residue)
The last line, taking a reciprocal mod 41, can be done by trial and
error or by Euclid's algorithm.
Noticing that only one value of D is a digit, the result is that N=5K,
the Celsius temperature is (5x10^(5K+1)+155)/41 and the Fahrenheit
.....
temperature is (9x10^(5K+1)+1591)/41; or [1]2195121955[1], where
..... .....
5/41=0.12195 and 9/41=0.21951.
For an easy ObPuzzle, try this with negative temperatures, where the
digits cycle but the minus sign stays in place. For a harder
ObPuzzle, make the minus sign cycle with the digits.
About a year ago, rec.puzzles searched for cases of a Fahrendrome,
whose Celsius equivalent has the same digits in reverse. I believe
that for the case of positive integers, it was shown there are none.
Suppose we allow decimal fractions, and require that the digits from
the first nonzero digit through the last nonzero digit be reversed? I
didn't find any of them, either, but I'm not sure I looked carefully
enough. What if we allow negatives? Certainly -40F=-40C, but are
there others?
-- Dan Hoey <Hoey@AIC.NRL.Navy.Mil>, July 1994
Andreas Stabel replied:
> The next three solutions to the Celsius and Fahrenheit version are:
> 2941176470588235275
> 29411764705882352941176470588235275
> 294117647058823529411764705882352941176470588235275
> There seems to be a pattern here !
> Could anyone find the general solution ?
Andreas does not say how he got these numbers. Perhaps he used a
computer but, remarkably, it turns out that pencil and paper are
enough to obtain the above and the general solution.
Let the Celsius temperature be C and its Fahrenheit equivalent be F.
Let the digits of C be u[alpha]vw where [alpha] represents missing
digits. e.g. If C = 387592 then alpha = 875. We will treat alpha as
a number in its own right. We have two ways of calculating F.
By FORMULA: F = (9/5)*C + 32 or by ROTATION: F = wu[alpha]v
And, of course, the two methods give the same result. First note that
the rotation won't work if w = 0. But C must be divisible by 5 so we
have w = 5.
Next note that (by formula) (1.8)*C < F < (2.2)*C. Then we have
(1.8)*u[alpha]v5 < 5u[alpha]v < (2.2)*u[alpha]v5. Let's show from
this that u <> 3. If u = 3 then C is at least 300--- (where the
dashes represent some fixed number of additional digits) then by
formula F > 540---. But by rotation F <= 539---, contra. So u <> 3.
Eliminating other impossible values for u is easier and we see that
u = 2.
So C = 2[alpha]v5. By rotation, the last digit of F is v. Note that
if we are given v we can calculate the last digit by formula even
though we don't know alpha. e.g. Suppose v = 3. Then we have: Last
two digits of C are 35. Then 9*C ends in 15. Then (9*C)/5 ends in 03.
Then last digit of (9*C)/5 + 32 = 5 <> v. So v cannot be 3. By a
process of elimination (check this for yourself) we are left with
v = 7.
Then C = 2[alpha]75 and F = 52[alpha]7
Then C = 2*(10^k) + 100*alpha + 75, where there are k + 1 digits in C.
Then, by formula, F = 36*(10^(k-1)) + 180*alpha + 167.
But from F = 52[alpha]7 we have F = 52*(10^(k-1)) + 10*alpha + 7.
Then 36*(10^(k-1)) + 180*alpha + 167 = 52*(10^(k-1)) + 10*alpha + 7.
Then alpha = (16/17)*(10^t - 1) where t = k - 2.
Question: If alpha is of the above form, is C = 2[alpha]75 a solution
to our problem? Answer: Yes, and the proof is essentially the
reversal of the steps we just took. I leave that part as an exercise.
If alpha = (16/17)*(10^t - 1) then 17 divides 10^t - 1. For which t
is this so, and what quotients do we get when we do the division?
Here's where the pencil and paper come in. 10^t - 1 is just
"t nines". We don't need to figure out in advance what t is. Just
write lots of 9's down on the paper and start dividing by 17.
Like this
588.....
|---------------------
17|999999999999999999999
Keep going until you do a step which leaves no remainder. Turns out
you need 16 nines and the quotient is 588235294117647, a 15 digit
number we will call Q1. Our smallest alpha is then the 16 digit
16*Q1 = 9411764705882352
Call this number Q2. First note that our first solution is
2941176470588235275 which agrees with Andreas's post -- So great
minds really do think alike. {:-)
Going back to dividing lots of nines by 17. Our next integer quotient
comes with a dividend of "32 nines" and the quotient is [Q1]0[Q1].
i.e. 588235294117647 0 588235294117647. What happens when you multiply
this one by 16? You get [Q2][Q2]. In general
alpha = 16 * ( [Q1]0[Q1]0 ...[Q1]) = [Q2][Q2]...[Q2]
So our general solution is C = 2[alpha]75 where alpha consists of
any number of repetitions of 9411764705882352.
NOTE: An analysis this messy could obviously be improved on.
-- Barry Paul <barry.paul@hofbbs.com> (July 1994)