July 28, 2013
On Friday morning, a group of black teenage boys sat around
a conference-room table in North Beach,
MacBook Airs open, as they debated the
best way to code the Fibonacci Sequence.
It's a classic problem of computer science,
figuring out an algorithm that spits out
a series of numbers generated by adding up
the two preceding ones: 0, 1, 1, 2, 3, 5, 8,
13, 21 and so on.
The lesson wasn't simply designed to teach
the high school students the Python
programming language they were working in.
It was calibrated to get them to think logically,
so that they can eventually work in any
 language.
Their mentor, developer and entrepreneur
Kurt Collins, guided the discussion with a 
delicate blend of sarcasm, wit and tough love.
At one point he made Johnnel White, going into
his sophomore year at Vallejo High School, 
erase the formula he'd carefully transcribed
from his laptop onto the whiteboard.
"If you understand the logic, you don't have to
memorize it," he said.
The students are members of the Hidden Genius
Project, an initiative formed last year by nine
technology professionals, nonprofit executives
and teachers who wanted to steer more minorities
into the growing and often lucrative industry.
Use the link above to read more about this
education offering for teenagers.  But now,
back to the problem:
Let's have the Haggin Museum docents and 
friends consider the implications here, then 
we'll take a stab at the problem.  John Dierking
could probably weigh in on this too.
Solving the problem:
To create a program that produces the Fibonacci
series of numbers, advise your teenagers that they 
should always ask a question like this of their 
programming instructors.  "What should our 
program OUTPUT look like?"  The output is simply 
a printout of the results after the program runs 
and finally arrives at the step to print out a sheet 
of numbers.  You'd be surprised how some 
instructors forget to tell you what output is desirable 
as the final product.  Let's assume that we want 
a sheet of printed numbers like the one above:
0, 1, 1, 2, 3, 5, 8, 13, 21 and so on.  Or, printed 
vertically down the page as we will choose to do here.
In programming languages, your student is allowed 
to "declare a variable".  This puts a God-like power 
in your student because a student can simply say, 
"The variable X now exists!"  or "The variable, 
RESULT, now exists!"  Let's continue with RESULT.  
If you say RESULT exists, it therefore does exist 
simply because you said so!  In a running program, 
the human speaks commands to the machine, 
sort of like this.  "I have written the command,  
RESULT=0."  The machine responds, upon reading 
your command, by reserving a place in its memory 
called RESULT.  It stays silently hidden from view
in the memory and carries a value of 0  (zero).  
Now let's try to imagine the program as it might look 
while actually working:
FIRST NUMBER = 0
SECOND NUMBER = 1
RESULT = FIRST NUMBER + SECOND NUMBER
(Notice here that we just created a variable called 
RESULT simply by saying that it's name is RESULT 
and that it has a value equal to 0+1,  which is 1.)
PRINTOUT FIRST NUMBER    (a zero gets printed)
PRINTER GO TO THE NEXT BLANK LINE DOWN 
AND WAIT
PRINTOUT SECOND NUMBER    (a 1 gets printed)   
Now we'll skip the commands to the printer and 
assume we go down a line after each number is printed,
otherwise it's tedious to say all that here.  Look back 
at the Fibonacci numbers to realize that we are trying 
to make the machine work its way from left to right 
and also actively create the next rung in its left to right,
increasing, ladder.
FIRST NUMBER =SECOND NUMBER  
(FIRST NUMBER is now 1 and no longer zero)
RESULT = FIRST NUMBER + SECOND NUMBER
so RESULT is now 2.          (1 +1=2)
FIRST NUMBER = SECOND NUMBER   (1 is still 1)
SECOND NUMBER = RESULT  (SECOND 
NUMBER now 2)
RESULT = FIRST NUMBER + SECOND NUMBER  
or 1+2=3)         RESULT has a value of 3.
FIRST NUMBER=SECOND NUMBER  
( FIRST becomes 2)
SECOND NUMBER = RESULT  (Second is now 3)

RESULT = FIRST NUMBER + SECOND NUMBER 
(Test this as, 2 +3=5            RESULT now equals 5.
FIRST NUMBER = SECOND NUMBER    
(FIRST is now 3)
SECOND NUMBER = RESULT  
(SECOND NUMBER now 5)
RESULT = FIRST NUMBER + SECOND NUMBER    
or 3+5=8)         RESULT has a value of 8.
FIRST NUMBER=SECOND NUMBER   
( FIRST becomes 5)
SECOND NUMBER = RESULT   (8)

RESULT = FIRST NUMBER + SECOND NUMBER 
(Test this as, 5 +8=13     RESULT now equals 13.
This process then continues to infinity  or until 
your printer runs out of ink or paper.  
The clever younger programmer can then add a few
twists to this.  Once he learns how to declare a 
DOWHILE loop, he can command the computer 
to stop this endless process once some kind of 
"counter" variable reaches or exceeds "one thousand" 
printed numbers or some such limit. That way, 
it reaches a stopping point and you won't have to 
pull the plug on your runaway computer.  In coding 
the above example, it becomes clear that it is possible 
to make errors in logic because the variables 
are constantly changing chameleon-like or 
like some Cheshire Cat.  
The "I'm not there anymore" quality of the variables 
can cause you to lose your way, so concentration is 
very necessary.  You can also compress this process 
by looping back after RESULT is made and go back 
to the top of the sequence and proceed through again. 
This saves on a lot of typing at the keyboard. 
Might as well invent some shortcuts!  Finally, computer programming 
teachers will advise the young 
programmer to "de-bug" your 
program by 
stepping through it with a note pad and 
writing down 
the numbers just to see that they change as you 
want them to.  Okay, that's enough demonstrating 
for now.  
Encouraging Your Student
First, it is sometimes necessary to inform 
middle-school and high-school students about 
computer programming and how to approach it 
as a subject.  Tell students that computer 
programming IS NOT math.  Even if it can be used 
to solve math problems, programming is more
a skill and even a craft involving logical thinking, 
organizing and some visual presentation craft.
It is a subject that both boys and girls can become 
excited about once they realize that it becomes 
fun to do and work to complete programs.
One metaphor that can describe programming 
is that of putting an electric train down on a hard floor.  
You lay down tracks for the train to follow.  
In a program, you lay down a track for the computer 
to follow, doing one step after another.  Train sets 
can have other tracks on the side or even inside 
loops of tracks which can be constructed within 
the larger layout.  Programming languages have 
entire lexicons of commands allowing you to 
make use of pre-constructed "tools" that perform 
work in your programs. Students can become 
excited to see how many tricks they can perform.  
If you discover an error in the above logic, 
by all means post your comment to advise of the error.