**Theorem 1. **

.

Firstly, let denote the set of natural numbers which have a base 3 expansion containing only the digits and . The following theorem from [1] will be used to prove theorem 1.

**Theorem 2.** (Corollary 4.10 of [1]). The Motzkin numbers satisfy

if ,

if or ,

otherwise.

We will first examine the nature of the set . We have

**Theorem 3.** The asymptotic density of the set is zero.

**Proof: **

Choose . Then and

as .

** .**

**Proof of Theorem 1.**

Since the asymptotic density of is zero, so is the asymptotic density of the sets for . Therefore Theorem 2 implies that

and the result follows.

** .**

[1] Deutsch, E., & Sagan, B. E. (2006). Congruences for Catalan and Motzkin numbers and related sequences. Journal of Number Theory, 117(1), 191–215. http://doi.org/10.1016/j.jnt.2005.06.005

]]>and

for integers .

**Theorem 1.** Let with and . Then the asymptotic density of the set is . In addition the asymptotic density of the set is .

**Proof.**

We firstly look at . We have, for fixed ,

where is an error term introduced by not rounding down to the nearest integer. So, letting

,

we have

where the new error term satisfies .

Then

Since and

.

The proof for is very similar. With and defined as above we have for fixed ,

and

and

.

**.**

where are the Catalan numbers. The following result is established in [1]

**Theorem 1** (Theorem 5.5 of [1]). The nth Motzkin number is even if and only if for and . Moreover, we have

if or

if

where is the number of digit 1’s in the base 2 representation of .

**Remark 2.** The 4 choices for in the above theorem give 4 disjoint sets of numbers .

**Theorem 3**. Each of the 4 disjoint sets defined by the choice of in Theorem 1 has asymptotic density in the natural numbers.

**Proof:** Use the result for the set of Theorem 1 of the post here with .

.

**Corollary 4: **The asymptotic density of

is .

The asymptotic density of

is .

The asymptotic density of each the sets

and is .

**Remark 5**: The first 2 statements of Corollary 4 follows immediately from theorems 1 and 3. The third statement follows from the observation that the numbers of 1’s in the base 2 expansion of is equally likely to be odd or even and therefore the same applies the the number of 1’s in the base 2 expansion of . Since the asymptotic density of the 2 sets combined is (from Theorems 1 and 3), each of the two sets has asymptotic density of .

[1] Eu, S.-P., Liu, S.-C., & Yeh, Y.-N. (2008). Catalan and Motzkin numbers modulo 4 and 8. European Journal of Combinatorics, 29(6), 1449–1466. http://doi.org/10.1016/j.ejc.2007.06.019

]]>where are the Catalan numbers. The following result is established in [1]

**Theorem 1 (Theorem 5.4 of [1]). **The Motzkin number is divisible by if and only if is one of the following forms

where and .

**Theorem 2: **The asymptotic density of numbers of the first form in theorem 1 is . Numbers of the fourth form also have asymptotic density . The asymptotic density of numbers of the second and third forms in theorem 1 is each.

**Corollary 3: **The asymptotic density of is .

**Remark 4**: Corollary 3 follows immediately from theorems 1 and 2 and the disjointness of the 4 forms of integers listed in theorem 1.

**Remark 5**: Numerical tests also show that roughly 22.5% of Motzkin numbers are congruent to each of .

**Proof of Theorem 2.**

Firstly consider numbers of the form . As we are interested in asymptotic density it is enough to look at numbers of the form . We have, for fixed ,

where is an error term introduced by not rounding down to the nearest integer. So,

where the new error term satisfies . Then

.

Since

.

A similar argument can be used to establish the asymptotic densities of the other 3 forms of numbers in the theorem.

**.**

[1] Deutsch, E., & Sagan, B. E. (2006). Congruences for Catalan and Motzkin numbers and related sequences. Journal of Number Theory, 117(1), 191–215. http://doi.org/10.1016/j.jnt.2005.06.005

]]>Corollary 2 of the previous post established that

This result can be used to show that the asymptotic density of the set is

To this end let for some Then and

So, as mentioned in the previous post

And so

where is a polynomial in of degree with coefficients depending on . Since is fixed and for fixed the second term above is zero in the limit and

This result is not surprising given the highly composite nature of the Catalan numbers. In general we would also expect that the same result holds with replaced by any natural number.

]]>

The Catalan numbers are defined by

This note will use results obtained by Liu and Yeh in [1] to obtain a formula for the number of which are divisible by where

Firstly, as in [1], let the p-adic order of a positive integer n be defined by

and the cofactor of n with respect to be defined by

In addition the function is defined by

For a number p, we write the base p expansion of a number n as

where and

Then the function is the sum of the p-adic digits of a natural number n (i.e. the sum of the digits of n when n is written in base p). Here we will only be interested in the case . Then

**Theorem 1**:

**Corollary 2**:

**Corollary 3**:

**Proof of Theorem 1:**

Let . Then

for some arbitrary . Writing in base 2 we have

where there are s 0’s at the end and is arbitrary. So,

where there are s 1’s at the end and is arbitrary. It can be seen that

Since and the possible base 2 representations of n are

with

with

.

.

.

with and 1’s at the end.

Therefore, counting each of these possibilities and using the fact that gives

The following result appears in [1].

**Theorem 4 (Corollary 4.3 of [1]): **In general, we have In particular, if and only if , and if and only if

Corollary 2 follows from Theorem 1 and Theorem 4 above since

from Theorem 4

from Theorem 1

since

From Theorem 4,

from Theorem 1.

[1] Liu, S.-C., & Yeh, J. (2010). Catalan numbers modulo . *J Integer Sequences*. **Vol 13** (2010) Article 10.5.4

I think it is fairly clear that most people prefer to sit “facing forward” and some people claim “facing backwards” makes them ill. Observation also suggests that people also have a preference for the side of the carriage on which they sit. I have not tested this, but have observed that people prefer to sit on the left side of the carriage with their right side closest to the middle aisle. It is a matter of speculation as to why this should be the case. It may be a security instinct. I recall reading that the British originally established left hand travel on roads to allow travellers to have their right arm free to defend themselves when they passed people coming from the opposite direction. Perhaps a similar instinct makes people choose to sit on the left side of trains. Of course this would indicate that left handed people should have a preference for the right side of the carriage.

There is also a subsection of people ( I don’t know how large) who prefer to sit in one of the four corners of the carriage with their back to the carriage wall so that they are facing into the carriage. I don’t know if security, politeness or some other reason is responsible for this preference. Was it Doc Holliday who would always sit with his back to the wall facing the door when in a pub? ]]>

The title is a little contentious since there are some restrictions. Obviously cars can’t speed when other cars or traffic lights get in the way. However, when there are no restrictions on speed other than the speed limit itself, it seems most drivers speed most of the time.

The proof involves sampling from a population to estimate the proportion of cars that are speeding. At each point in time each car on the road is either speeding or not speeding. I have assumed that the proportion of cars which are speeding does not change over time. This is a necessary assumption as the sample is collected at different points in time so we want to assume we are still sampling from the same population.

The sampling itself is fairly straight forward. Just jump in the car and drive (and count). Drive just above the speed limit on a road where there are no traffic lights and traffic conditions do not impede driver’s speeds. Count the number of cars you pass (non-speeders) and the number of cars that pass you (non-non-speeders). Collect enough sample points as per standard statistical theory and use the results to estimate the proportion of drivers who speed.

I have done the experiment and the result is summarised by the title of the story. It’s clear now why my dad used to say that most drivers consider the speed limit as a minimum rather than a maximum.

One of the strange characteristics of the driver population is that individual cars can change their state from one time to another by either slowing down or speeding up. This is different from the usual scenario where for example the proportion of defectives on a production line is estimated. An item that is defective stays defective. The car is like Schrödinger’s cat in the famous thought experiment.

As an addendum, I note that The Age newspaper recently (2 June 2017) published an article bearing out the above observation using a survey of drivers. See the story Motorists behaving badly

]]>Motorists behaving badly … and they know it Speeding, texting while driving and answering hand-held mobile phones. These dangerous driving practices are rife on Victorian roads.

Zenityis free software and a cross-platform program that allows the execution of GTK+ dialog boxes in command-line and shell scripts.

Scripts run from the command line generally by default print results to the command line. For example this simple script prints the md5 hashes for files in a directory.

#!/bin/sh # # This script prints md5 output for files # for file in *.* do rhash -M $file done

In Ubuntu scripts can also be run from the nautilus context menu. Scripts are first placed in a designated location (depending on the Ubuntu version). The scripts in this location can then be run on files in nautilus by selecting the file(s), right clicking and choosing the script. As there is no terminal the script will not be able to display text by default. Zenity will allow the script to display text in a dialogue box. Here is an example of a script which allows you to select a number of files and print their md5 hashes to a dialogue box.

#!/bin/sh # # This script prints md5 output for files # ZENITY=$(which zenity) # Check if we have selected any files... if [ -z "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" ]; then $ZENITY --error --text="No files selected" exit 0; fi md5Output="" for file in $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS do a=$md5Output b=`rhash -M "$file"` md5Output=$a"\n"$b done $ZENITY --info --text="$md5Output"]]>