Java examples for Object Oriented Design:Method
Displaying Fibonacci sequences using recursion
public class Main { public static int Fibonacci(int n) { if (n <= 1) return 1;// www .j a v a2 s . co m else return Fibonacci(n - 1) + Fibonacci(n - 2); } public static void main(String[] args) { int i; for (i = 0; i <= 30; i++) System.out.print(Fibonacci(i) + " "); } }