Solution accepted in spoj but time limit exceed in codechef

I submitted my answer in SPOJ for http://www.codechef.com/problems/PRIME1/ accepted with time 1.72. But I am getting TLE in codechef. My solution is http://www.codechef.com/viewsolution/6377029