nave@lemmy.zip to Lemmy Shitpost@lemmy.worldEnglish · edit-21 year agotrashmessage-square43fedilinkarrow-up1597arrow-down16
arrow-up1591arrow-down1message-squaretrashnave@lemmy.zip to Lemmy Shitpost@lemmy.worldEnglish · edit-21 year agomessage-square43fedilink
minus-squareRentlar@lemmy.calinkfedilinkarrow-up87·edit-21 year agoThey call me a StackOverflow expert: private bool isEven(int num) { if (num == 0) return true; if (num == 1) return false; if (num < 0) return isEven(-1 * num); return isEven(num - 2); }
minus-squareJohanno@feddit.delinkfedilinkarrow-up16·edit-21 year agoStackoverflowException. What do I do now? Nvm. Got it. if(num % 2 == 0){ int num1 = num/2 int num2 = num/2 return isEven(num1) && isEven(num2) } if(num % 3 == 0){ int num1 = num/3 int num2 = num/3 int num3 = num/3 return isEven(num1) && isEven(num2) && isEven(num3) } Obviously we need to check each part of the division to make sure if they are even or not. /s
They call me a StackOverflow expert:
StackoverflowException.
What do I do now?
Nvm. Got it.
Obviously we need to check each part of the division to make sure if they are even or not. /s