|
|
@@ -23,13 +23,22 @@ public class Recursive {
|
|
|
}
|
|
|
|
|
|
private void runFibonacciTest() {
|
|
|
- // TODO Auto-generated method stub
|
|
|
-
|
|
|
+ System.err.println("Running recursive fibonacci test...");
|
|
|
+ System.out.println(calcFibonacci(20));
|
|
|
+ }
|
|
|
+
|
|
|
+ public int calcFibonacci(int n) {
|
|
|
+ if(n == 0)
|
|
|
+ return 0;
|
|
|
+ else if(n == 1)
|
|
|
+ return 1;
|
|
|
+ else
|
|
|
+ return calcFibonacci(n - 1) + calcFibonacci(n - 2);
|
|
|
}
|
|
|
|
|
|
private void runFileTest() {
|
|
|
- System.err.println("Running recursive file test");
|
|
|
- System.out.println(viewFiles("C:\\Users\\Kenneth\\Downloads\\SAH"));
|
|
|
+ System.err.println("Running recursive file test...");
|
|
|
+ System.out.println(viewFiles("."));
|
|
|
}
|
|
|
|
|
|
private String viewFiles(String path)
|
|
|
@@ -41,7 +50,7 @@ public class Recursive {
|
|
|
for(File f : files)
|
|
|
{
|
|
|
if(f.isDirectory())
|
|
|
- str += "\n" + f.getName() + "\n\t" + viewFiles(f.getAbsolutePath());
|
|
|
+ str += "\n" + f.getName() + "\t" + viewFiles(f.getAbsolutePath());
|
|
|
else
|
|
|
str += "\n\t" + f.getName();
|
|
|
}
|