Initial Commit
This commit is contained in:
19
Submissions/As7/CS1083-A7-StudentFiles-W2021/Seq.java
Normal file
19
Submissions/As7/CS1083-A7-StudentFiles-W2021/Seq.java
Normal file
@ -0,0 +1,19 @@
|
||||
/**
|
||||
A utility class that provide methods to compute elements of the
|
||||
recursive sequence.
|
||||
@author Leah Bidlake
|
||||
*/
|
||||
|
||||
public class Seq{
|
||||
|
||||
/**
|
||||
Recursively computes seq(n).
|
||||
@param n Non-negative integer.
|
||||
@return int Element n in the recursive sequence.
|
||||
*/
|
||||
public static int seqR(int n){
|
||||
//TODO: this should look very much like the
|
||||
//mathematical specification
|
||||
}
|
||||
|
||||
}
|
23
Submissions/As7/CS1083-A7-StudentFiles-W2021/TestSeq.java
Normal file
23
Submissions/As7/CS1083-A7-StudentFiles-W2021/TestSeq.java
Normal file
@ -0,0 +1,23 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
A simple driver that uses the Seq class to compute the
|
||||
nth element of the sequence.
|
||||
*/
|
||||
public class TestSeq{
|
||||
|
||||
public static void main(String[] args){
|
||||
|
||||
int n, seqRec, seqMem, seqIter;
|
||||
|
||||
Scanner scan = new Scanner(System.in);
|
||||
System.out.print("Enter a positive integer: ");
|
||||
n = scan.nextInt();
|
||||
|
||||
seqRec = Seq.seqR(n);
|
||||
System.out.println("seqR(" + n + ") is: " + seqRec);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user