Recursion Output Practice - Part 2 (Binary Representation)

PHOTO EMBED

Sun Feb 06 2022 20:31:27 GMT+0000 (Coordinated Universal Time)

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

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

class GFG {

	
	static void fun(int n)
	{
		if(n == 0)
			return;
		
		fun(n / 2);

		System.out.println(n % 2);

	}
    public static void main(String [] args) 
    {
        fun(7);
    }

}
content_copyCOPY

OUTPUT : ----------- 1 1 1