sigsegv error

Pls help guys.getting SIGSEGV error for the problem http://www.codechef.com/problems/GCD2.
Here is my soln http://www.codechef.com/viewsolution/4394846