Fun with Recursion - Introduction (Example - 2)

PHOTO EMBED

Sun Feb 06 2022 20:18:14 GMT+0000 (Coordinated Universal Time)

Saved by @Uttam #java #gfg #geeksforgeeks #lecture #recursion #intro #basecase #recursivefunction

import java.io.*;
import java.util.*;

class GFG {

	
	static void fun1(int n)
	{
		if(n == 0)
			return;

		System.out.println("GFG");

		fun1(n - 1);
	}
    public static void main(String [] args) 
    {
        fun1(2);
    }

}
content_copyCOPY

Example - 2 : Learn how to perform Recursion (The process in which a function calls itself) 1.) Base case : Stop condition OR Recursion termination 2.) Recursive function OUTPUT : ----------- GFG GFG