ap-1 ≡ 1 (mod p) where p is co-prime to a
here a varies from 1 to 2004, all of them will give remainder 1 except for a = p, 2p, 3p, ......, [2004/p] p which will give remainder 0
(here [.] is greatest integer function)
so final remainder = 2004 - [2004/p]
this should be divisible by p for which p should be odd prime factor of 2004