_limit = 500000 void local fn ErdosNicolasNumbers long i, j, sum( _limit ), count( _limit ) for i = 0 to _limit sum(i) = 1 count(i) = 1 next for i = 2 to _limit j = i + i while ( j <= _limit ) if sum(j) == j then printf @"%8ld == sum of its first %3ld divisors", j, count(j) sum(j) = sum(j) + i count(j) = count(j) + 1 j = j + i wend next end fn fn ErdosNicolasNumbers HandleEvents