CSC 216 F09/
Jump to navigation
Jump to search
Background
This is a simple exercise for finding recursive equations and writing them as Java code.
Props
1. Whiteboard
2. Access to a Java editor
Procedure
1) Give each row a sequence of numbers.
Ex:
a) 2, 6, 10, 14,...
b) 0, 1, 0, 1...
c) 2, 6, 12, 20...
d) 1, 4, 9, 16...
2) Then have each row work together to find the recursive definition for the sequences.
Ex:
a) 4n-2
b) 1+(-1)^n
c) n(n + 1)
d) n^2
3) Lastly, each group should write Java code to implement the recursive equation and submit via Google Docs.
Ex:
a)
public int recursion( int n ){
int a = 0; if(n == 1) a = 2; else a = recursion( n - 1 ) + 4; return a;
}
By: David Duran & Dereck Allred