Back in Chapter 9 your VIC added up the first 1000 odd numbers. In that case we simply told the computer to increment by two to reach another odd number to add into the sum. Now we pose the problem: how do we teach your VIC to figure out whether any given integer is even or odd? This innocent problem has a number of solutions. We will use a variant of a solution to this problem to examine a classic question in probability—the Random Walk. We will write a program that will calculate the average time it takes a drunken bug reach the edge of the screen. For the computer to realize that the little fellow has reached the edge it has to solve a simple algebraic equation very similar to the one that solves...
Unable to display preview. Download preview PDF.