local fn ProperDivisors( n as long ) as CFArrayRef CFMutableArrayRef array = fn MutableArrayWithCapacity(0) if ( n < 2 ) then exit fn long i for i = 1 to n - 1 if ( n mod i == 0 ) MutableArrayAddObject( array, @(i) ) end if next end fn = array void local fn DoIt long n, count, num, max = 0 for n = 1 to 10 printf @"%2ld: %@",n,fn ArrayComponentsJoinedByString( fn ProperDivisors( n ), @" " ) next for n = 1 to 20000 count = len( fn Properdivisors( n ) ) if ( count > max ) max = count num = n end if next print: print num;@" has the most proper divisors with ";max end fn fn DoIt HandleEvents