14-section-1

14-section-1 - CS 106A Handout #14 June 30, 2009 Section...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Handout #14 CS 106A June 30, 2009 Section Handout #1—Simple Java This week in section, you will write two programs that get you started with Java. 1. The Fibonacci sequence In the 13th century, the Italian mathematician Leonardo Fibonacci—as a way to explain the geometric growth of a population of rabbits—devised a mathematical sequence that now bears his name. The first two terms in this sequence, Fib (0) and Fib (1), are 0 and 1, and every subsequent term is the sum of the preceding two. Thus, the first several terms in the Fibonacci sequence look like this: Fib (0) = 0 Fib (1) = 1 Fib (2) = 1 (0 + 1) Fib (3) = 2 (1 + 1) Fib (4) = 3 (1 + 2) Fib (5) = 5 (2 + 3) Write a program that displays the terms in the Fibonacci sequence, starting with Fib (0) and continuing as long as the terms are less than 10,000. Thus, your program should produce the following sample run: Fibonacci This program lists the Fibonacci sequence. 0 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/14/2010 for the course CS 106A taught by Professor Sahami,m during the Fall '08 term at Stanford.

Page1 / 2

14-section-1 - CS 106A Handout #14 June 30, 2009 Section...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online