How to print fibonacci series in reverse order using recursion in Java

1 Answer

0 votes
public class MyClass {
    private static void fib(int n, int a, int b) {
    	if (n > 0) {
    		fib(n - 1, b, a + b);
    		System.out.print(a + " ");
    	}
    }

    public static void main(String args[]) {
	    int N = 12;

	    fib(N, 0, 1);
    }
}




/*
run:

89 55 34 21 13 8 5 3 2 1 1 0 

*/

    

 



answered Nov 29, 2023 by avibootz
edited Nov 29, 2023 by avibootz
...