Not sure why it works in cpp.sh, probably some weird optimizations, but your formula for some reason doesn't use unsigned long long literals for integer calculation. The max xp you can have is 4,294,967,295 which is why you're only able to get up to 638, if you look at @Alpha's code snippet you...