Highly Composite Numbers
July 12, 2016
We give an answer in Julia:
function nod(x::Int64) # number of divisors n = 2 # every number is divisible by 1 and by itself for z = 2:div(x,2) if x % z == 0 n += 1 end end return n end function hcp(N::Int64 = 1000) # Highly Composite Numbers y =  # list of highly composite numbers z =  # list of corresponding number of divisors for x = 2:N n = nod(x) if n > z[end] push!(y, x) push!(z, n) end end return hcat(y, z) end
The calculation of the number of divisors is brute force, checking each z from 1 to n − 1 for divisibility. Function
hcp iterates from 2 to the limit and stores each number whose divisor count exceeds the current maximum.
Since ideone does not provide Julia, a corresponding Scheme program is available at http://ideone.com/3EjR09.
Pages: 1 2