public static void main ( String [] args ) {
       
	int range = 10000;
	int sum = 0;
	int a=0, b=0;
	for ( int i=1; i<=range; i++ ) {
	    a = gcd(i);  
	    b = gcd(a);  
	    if ( b == i && a != b ) {
		sum = sum + a;
	    }
	}
	System.out.println("sum = " + sum);
    }