36 lines
958 B
Java
36 lines
958 B
Java
/*
|
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
|
*/
|
|
package bigintegerfibonacci;
|
|
|
|
/**
|
|
*
|
|
* @author caleb
|
|
*/
|
|
public class StackSize {
|
|
|
|
public static void main(String[] args) {
|
|
|
|
try {
|
|
//System.out.println(fact(1 << 15));
|
|
System.out.println(infinateRecursion(0));
|
|
}
|
|
catch (StackOverflowError e) {
|
|
System.err.println("true recursion level was " + level);
|
|
System.err.println("reported recursion level was " +
|
|
e.getStackTrace().length);
|
|
}
|
|
}
|
|
|
|
private static int level = 0;
|
|
public static long fact(int n) {
|
|
level++;
|
|
return n < 2 ? n : n * fact(n - 1);
|
|
}
|
|
public static long infinateRecursion(long n) {
|
|
level++;
|
|
return infinateRecursion(n++);
|
|
}
|
|
}
|