You know what's your mistake? You called IntPower from your own IntPower function, with undefined results, so it crashed.
1 2 3 4 5 6 7 8 9 10
long IntPower(long x, int n) {
if(n==0)
return 1;
elseif(n>0){
long xStart = x;
for(int i = 0; i < n; i++)
x = x * xStart; // You can also use "x *= xStart;"
return x;
}
}