
import java.io.File;
import java.io.IOException;

public class Sample2
{
    public static long binomial( int n, int k )
    {
        if( k == 0 || k == n )
            return 1;
        else
            return binomial( n - 1, k ) + binomial( n - 1, k - 1 );
    }

    public static String reverseString( String str )
    {
        if( str.equals( "" ) )
            return "";
        else
            return reverseString( str.substring( 1 ) ) + str.charAt( 0 );
    }

    public static void printEmptyFiles( File d )
    {
        if( !d.isDirectory( ) )
        {
            if( d.length( ) == 0 )
                System.out.println( d.getAbsolutePath( ) + " empty file" );
            return;
        }

        // d is definitely a directory
        File [ ] contents = d.listFiles( );

        if( contents.length == 0 )
            System.out.println( d.getAbsolutePath( ) + " empty directory" );
        else
            for( File f : contents )
                printEmptyFiles( f );
    }


    public static void findAllFiles( File d, String ext )
    {
        if( d.isDirectory( ) )
            for( File f : d.listFiles( ) )
                findAllFiles( f, ext );
        else
            if( d.getName( ).toLowerCase( ).endsWith( ext.toLowerCase( ) ) )
                System.out.println( d.getAbsolutePath( ) );
    }

    public static void main( String [ ] args )
    {
        int N = 4;
        for( int k = 0; k <= N; k++ )
            System.out.println( "b(" + N + "," + k + ") = " + binomial( N, k ) );

        System.out.println( reverseString( "abcdefghi" ) );

        printEmptyFiles( new File( "." ) );

        System.out.println( "All Java code: " );
        findAllFiles( new File( "." ), "JAVA" );
    }

}

