Java examples for Algorithm:Number
Calculate fibonacci recursively
public class Main { public static void main(String args[]) { int nums = fibonacci(8); System.out.println(nums);/* w w w. j a va2 s . c o m*/ } static int fibonacci(int n) { if (n <= 1) return 1; return fibonacci(n - 1) + fibonacci(n - 2); } }