I have been trying to solve this problem for a while now but made no progress. Can anybody help with TRENDGCD — Trending GCD at spoj. It is related to mobius function. Here is link to the problem: https://www.spoj.com/problems/TRENDGCD/