1. a and b are swapped over. Strange that this can be done without an intermediate int for storage. To see how it happens, trace the bitmap changes to a and b over the three assignments.

2. 3,082. You just count the 5 factors, there are enough 2s to pair them up with, remembering of course that multiples of 25 contribute 2 factors, multiples of 125 contribute 3, and so on.

3.


Suppose the statue is on the line OEPS, where P is the top of the plinth, and S the top of the statue, and E′E is the eye-line of Eratosthenes. So OE = e, OP = p and OS = s. Let c be the circle that passes through P and S and has EE′ as a tangent, T being the point of contact of EE′ with c. Suppose X is any other point in the plane of c. If X is on c, then angle PXS = PTS (Euclid III 21). If X is outside c, then PXS < PTS. So as X runs along EE′, PXS takes its maximum value when X is at T, so Eratosthenes needs to stand with eyes at T. We need to compute ET.

Let C be the centre of c and M the mid-point of PS. Then the radius PC = TC = EM, PM = MS and ET = MC, so that
ET2  =  MC2  =  PC2 – PM2  =  EM2 – PM2  =  (EM + PM)(EM – PM)  =  (EM + MS)(EM – PM) = ES.EP
Therefore
ET = √(ES.EP) = √[(se)(pe)]
Well, this is a solution for Euclid. Let us try it wih a bit of trigonometry. First we will need this
Lemma: The maximum value of  y  =  x
x 2 + a 2
  occurs when x  =  a.
To prove this, either solve dy/dx = 0, or simply note that
(xa) 2  ≥  0  ⇒  x 2 + a 2  ≥  2ax  ⇒  x
x 2 + a 2
  ≤   1
2a
and y attains this value 1/2a when x = a.

Let angles STP and PTE be α and β, as shown, and let length ET be x. We want the value of x that maximises α (equivalently, tan α). We make use of the identity,
tan(A + B)  =  tan A + tan B
1 – tan A tan B
Put –β for B and α + β for A, and we get,
tan α  =  tan(α + β) – tan β
1 + tan(α + β) tan β
But tan(α + β) = ES/x and tan β = EP/x, so
tan α  =  (ES – EP)x
x 2 + ES.EP
 =  SP   x
x 2 + a 2
where a = √(ES.EP). This has a maximum at x = a, and a is √[(se)(pe)].

4. The answer is ⅔. This can seem a bit odd at first. After all, the first ball in the bag is red with probability ½. Then the second ball is added and one drawn out. If it is white, the probability that the one in the bag is red is 1. If it is red, the probability that the one in the bag is red is ⅔. It seems to have gone up from ½ in either case. But ⅔ is right. This program checks it out,


#include <stdio.h>
#include <stdlib.h>

#define white 0
#define red 1

static int box[2];

static int random_bit(void) { return rand() & 1; }

/* trial() puts the balls in the box, and returns
   -1 if a white is drawn,
   0 if a red is drawn, with a white one left in the box,
   1 if a red is drawn, with a red one left in the box,
*/

static int trial(void) {
    box[0] = random_bit();  /* put a random ball in the box, white or red */
    box[1] = red;           /* put a red ball in the box */
    {  int i = random_bit();/* the ball to be drawn out */
       if (box[i] == white) return -1;
       /* so box[i] is red */
       return box[1 - i];   /* the other ball */
    }
}

int main() {

    int count = 0;
    int count_red = 0;

    while(count < 10000000) {
        switch (trial()) {
            case -1: break;
            case 1: count_red++;
            case 0: count ++;
        }
    }

    printf("In %d trials where a red ball is drawn, ", count);
    printf("the second ball was red %d times.\n", count_red);
    printf("In other words, nearly two thirds.\n", count_red);

    return 0;
}
Running this on my machine gives,
In 10000000 trials where a red ball is drawn, the second ball was red 6666603 times.
In other words, nearly two thirds.

5.
We will use the notation   nCr  =  n!
r! (nr)!
Let  sr(n)  =  n
Σ
i = 1
i r
Then  sr+1(n)  =  n
Σ
i = 1
i r+1  =  n
Σ
i = 1
(i + 1) r+1 + 1 – (n + 1) r + 1
         =  r+1C0 sr+1(n) + r+1C1 sr(n) + . . . + r+1Cr+1 s0(n) + 1 – (n + 1) r + 1

The sr+1(n) terms cancel, and r+1C1 = r + 1, so we get (writing sr for sr(n) from here on),
          sr  =  1
r + 1
{ (n + 1) r+1 – 1 – r+1C2 sr–1r+1C3 sr–2 – . . . – r+1Cr+1 s0 }

Note that s0 = n. The formula gives us in turn s1, s2, s3 . . . and here they are up to s5,

s0 = n
s1 = 1/2 n (n + 1)
s2 = 1/6 n (n + 1) (2n + 1)
s3 = 1/4 n (n + 1) (n2 + n)
s4 = 1/30 n (n + 1) (6n3 + 9n2 + n – 1)
s5 = 1/12 n (n + 1) (2n4 + 4n3 + n2n)
Here are a few more,
s6 = 1/42 n (n + 1) (6n5 + 15n4 + 6n3 – 6n2n + 1)
s7 = 1/24 n (n + 1) (3n6 + 9n5 + 5n4 – 5n3 – 2n2 + 2n)
s8 = 1/90 n (n + 1) (10n7 + 35n6 + 25n5 – 25n4 – 17n3 + 17n2 + 3n – 3)
s9 = 1/20 n (n + 1) (2n8 + 8n7 + 7n6 – 7n5 – 7n4 + 7n3 + 3n2 – 3n)
s10 = 1/66 n (n + 1) (6n9 + 27n8 + 28n7 – 28n6 – 38n5 + 38n4 + 28n3 – 28n2 – 5n + 5)

6. Suppose G is a group and |G| (the size of G) is even. Let S be the set of all elements g of G for which gg–1. Then for each g in S, S also contains g–1, and since no element has more than one inverse, |S| is even. Therefore |G – S| is even. But e, the identity element is in G – S, so |G – S| is at least 2, and so has an element he with h2 = e.

7.


Three people P, Q, and R, are in a square room ABCD. Put P in corner D and Q and R on AB and BC so that angles ADQ and CDR are 15°. There are 24 arrangements: each of the three people can be in one of the four corners, and the remaining two can swap positions.

8. ‘princes’.

9. G' is the reflection of G in the line AB, regarded as a mirror. So TG = TG', and GG' is at right angles to AB.


(We adopt a dodge here a bit like the one in puzzle 3.) Let FT + TG = l. Then for any point X on the ellipse FX + XG = l, and indeed this defines an ellipse. If then X is on AB we have FX + XG ≥ l, with equality only when X is at T. But for any X on AB, XG = XG', and FX + XG' clearly has a minimum value when FXG' is a straight line. And this occurs when X is at T, so FTG' is that straight line. Therefore angle ATF = BTG' (opposite angles) = BTG (similar triangles).

Inside an ellipsoidal mirror, a light ray from F will be reflected off the tangent plane at T towards focus G. If F is drawn leftwards towards infinity, you get a parabolic mirror, which, when pointed towards the sun, concentrates light at G and will light a magnesium strip etc.

10. Fortunatus’s purse is a Klein bottle.