From jacobson@math-cs.cns.uni.edu Mon Nov 4 11:28:40 2002 Date: Mon, 04 Nov 2002 11:28:03 -0600 (CST) From: Mark Jacobson To: 810-061-01@uni.edu, 810-061-02@uni.edu Subject: Recursion... As a follow-up to today's November 4th class, try to use both a for loop and a while loop to solve the following problem: Output the numbers 20, 30, 40, 50, ... through 200 to the applet window, using a new Text() object to store each one. 20 30 40 50 60 70 80 90 100 110 ... 190 200 Use the trinary operator (see your recursion handout from today and see page 189 for the trinary selection operator that selects one of two different expressions) to achieve the extra space in front of the 2 digit numbers. (Page 189 of Big Java book). The for statement is explained on page 236 of Big Java. Also, try to get the sum of the numbers 0, 1, 2, 3, ..., n-1, n by using RECURSION instead of using a while or a for loop. --------- We solved the public int sumSequence(int n) using both for and while loops. Try doing it recursively. Mark