Sphere Online Judge (SPOJ) - Problem COINS

i have used recursive function to solve problem given in above link.

but i am getting runtime error.

plz.. tell me what is the problem.

Code:long long int calc(long long int n) { long long int x,y,z,sum; if(n>1) { x=calc(n/2); y=calc(n/3); z=calc(n/4); sum =x+y+z; if(sum<n) { sum=n; } return sum; } else { return n; } }