09.12.2012 Views

Concrete mathematics : a foundation for computer science

Concrete mathematics : a foundation for computer science

Concrete mathematics : a foundation for computer science

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

“Known” like, say,<br />

harmonic numbers.<br />

A. M. Odlyzko and<br />

H. S. Wilf have<br />

shown that<br />

D:’ = [( $)“Cj ,<br />

where<br />

CM 1.622270503.<br />

3.3 FLOOR/CEILING RECURRENCES 81<br />

Fortunately there’s a way to simplify this algorithm if we use the variable<br />

D = 3n + 1 - N in place of N. (This change in notation corresponds to<br />

assigning numbers from 3n down to 1, instead of from 1 up to 3n; it’s sort of<br />

like a countdown.) Then the complicated assignment to N becomes<br />

D := 3n+l- (3n+1-D)-n-1 +(3n+1-D)-n<br />

and we can rewrite the algorithm as follows:<br />

D := 1;<br />

while D < 2n do D := [;Dl ;<br />

Js(n) := 3n+l -D.<br />

Aha! This looks much nicer, because n enters the calculation in a very simple<br />

way. In fact, we can show by the same reasoning that the survivor J4 (n) when<br />

every qth person is eliminated can be calculated as follows:<br />

D := 1;<br />

while D < (q - 1)n do D := [*Dl ;<br />

J,(n) := qn+l -D.<br />

(3.19)<br />

In the case q = 2 that we know so well, this makes D grow to 2m+1 when<br />

n==2”+1; hence Jz(n)=2(2m+1)+1 -2m+1 =21+1. Good.<br />

The recipe in (3.19) computes a sequence of integers that can be defined<br />

by the following recurrence:<br />

D(q) = 1<br />

0 1<br />

D’4’ =<br />

n<br />

L,,(q) <strong>for</strong> n > 0.<br />

q - 1 n-1 1<br />

(3.20)<br />

These numbers don’t seem to relate to any familiar functions in a simple<br />

way, except when q = 2; hence they probably don’t have a nice closed <strong>for</strong>m.<br />

But if we’re willing to accept the sequence D$’ as “known,” then it’s easy to<br />

describe the solution to the generalized Josephus problem: The survivor Js (n)<br />

is qn+ 1 -Dp’, where k is as small as possible such that D:’ > (q - 1)n.<br />

3.4 ‘MOD’: THE BINARY OPERATION<br />

The quotient of n divided by m is Ln/m] , when m and n are positive<br />

integers. It’s handy to have a simple notation also <strong>for</strong> the remainder of this

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!