You are viewing a single comment's thread. Return to all comments →
Unfortunately, I haven't arrived at that simple algebraic formula. Therefore, I solved the problem counting the number of all possible common divisors algorithmically.
import Data.List ( group )
count' :: [Int] -> [Int]
count'  = 
count' [x] = [x]
count' (x:xs) = [x] ++ count' xs ++ map (x*) (count' xs)
count :: [Int] -> Int
count = sum . count'
-- 1 stands for the trivial divisor (one)
numDivisors m l = 1 + count ns
where ns = map length $ group $ factorize $ gcd m l