Program to find the number from given holes | Java implementation of the above approach ; Function that will find out the number ; If number of holes equal 0 then return 1 ; If number of holes equal 0 then return 0 ; If number of holes is more than 0 or 1. ; If number of holes is odd ; Driver code ; Calling Function
import java . io . * ; class GFG { static void printNumber ( int holes ) { if ( holes == 0 ) System . out . print ( "1" ) ; else if ( holes == 1 ) System . out . print ( "0" ) ; else { int rem = 0 , quo = 0 ; rem = holes % 2 ; quo = holes / 2 ; if ( rem == 1 ) System . out . print ( "4" ) ; for ( int i = 0 ; i < quo ; i ++ ) System . out . print ( "8" ) ; } } public static void main ( String [ ] args ) { int holes = 3 ; printNumber ( holes ) ; } }