library(numbers)
for(i in 1:9)
for(j in 0:9)
for(k in 0:9){
x=i*100100+j*1010+k*101
if(!isPrime(x)){
p=primeFactors(x)
if((prod(apply(outer(p,p,F="=="),1,sum)%%2))&
(!max((x-1)%%(p-1))))break()}}

resulting into the number 101 101, since its prime factors are

start with the number 1 and then try to reach a target number through a series of steps. For each step, you can always choose to double the number you currently have. However, if the number happens to be one (1) more than an odd multiple of 3, you can choose to “reduce” — that is, subtract 1 and then divide by 3. What is the smallest positive integer one cannot reach this way?

Which I turned into R steps (while waiting for flight AF19 to Paris)

but running an exhaustive search till 10⁸ did not spot any missing integer… Maybe an April fool joke (as the quick riddle was asking for the simplest representation of (x-a)(x-b)…(x-z)…!)

What was the probability that none of the 40 people had birthdays this month? What is the probability that there is at least one month in the year during which none of the 40 people had birthdays (not necessarily this month)?

Assuming the same number of days in all months, the probability that one individual is not born in March is 1/12 and hence the probability that none of 40 (independent!) persons are not born in March is (11/12)⁴⁰, about 3%. The second question can be solved by reading Feller’s chapter on the combination of events (1970, Chapter IV, p.102). The probability that all months are seeing at least one birthday is

which can be checked by a quick R simulation. The complement 0.326 is thus close to 11 x 0.03!

The riddle from The Riddler of 19 Feb. is about the Bernoulli Galton-Watson process, where each individual in the population has one or zero descendant with equal probabilities: Starting with a large population os size N, what is the probability that the size of the population on the brink of extinction is equal to one? While it is easy to show that the probability the n-th generation is extinct is

I could not find a way to express the probability to hit one and resorted to brute force simulation, easily coded

for(t in 1:(T<-1e8)){N=Z=1e4
while(Z>1)Z=rbinom(1,Z,.5)
F=F+Z}
F/T

which produces an approximate probability of 0.7213 or 0.714. The impact of N is quickly vanishing, as expected when the probability to reach 1 in one generation is negligible…

However, when returning to Dauphine after a two-week absence, I presented the problem with my probabilist neighbour François Simenhaus, who immediately pointed out that this probability was more simply seen as the probability that the maximum of N independent geometric rv’s was achieved by a single one among the N. Searching later a reference for that probability, I came across the 1990 paper of Bruss and O’Cinneide, which shows that the probability of uniqueness of the maximum does not converge as N goes to infinity, but rather fluctuates around 0.72135 with logarithmic periodicity. It is only when N=2^n that the sequence converges to 0.721521… This probability actually writes down in closed form as

(which is obvious in retrospect!, albeit containing a typo in the original paper which is missing a ½ factor in equation (17)) and its asymptotic behaviour is not obvious either, as noted by the authors.

On the historical side, and in accordance with Stiegler’s law, the Galton-Watson process should have been called the Bienaymé process! (Bienaymé was a student of Laplace, who successively lost positions for his political idea, before eventually joining Académie des Sciences, and later founding the Société Mathématique de France.)

As I was waiting for my boat on a French Guiana beach last week, I thought back about a recent riddle from The Riddler where an item does a random walk over a sequence of N integers. Behind doors. The player opens a door at the same rate as the item, door that closes immediately after. What is the fastest strategy to catch the item? With a small value of N, it seemed that repeating the same door twice and moving from 1 to N and backward was eventually uncovering the item.

Here is the cRude code I later wrote to check whether or not this was working:

p=1+t%%N #starting item position
h=v=s=m=1 #h=door, v=attempt number, s=direction, m=repeat number
while(h-p){
p=ifelse(p==1,2, #no choice
ifelse(p==N,N-1, #no choice
ifelse(p==h-1,p-1, #avoid door
ifelse(p==h+1,p+1, #avoid door
p+sample(c(-1,1),1))))) #random
m=m+1
if(m>2){
h=h+s;m=1
if(h>N){
h=N-1;s=-1}
if(!h){
s=1;h=2}
}
v=v+1

and the outcome for N=100 was a maximum equal to 198. The optimal strategy leads to 196 as repeating the extreme doors is not useful.