▲ 444 ▼ Infallible Code (lemmy.ml) submitted 1 year ago by sirico@feddit.uk to c/programmerhumor@lemmy.ml 134 comments fedilink hide all child comments
[+] redxef@feddit.org 38 points 1 year ago* (last edited 5 months ago) (3 children) [deleted] permalink fedilink source hideshow 6 child comments replies: [–] OddMinus1@sh.itjust.works 3 points 1 year ago* (1 child) Could also be done recursive, I guess? boolean isEven(int n) { if (n == 0) { return true; } else { return !isEven(Math.abs(n - 1)); } } permalink fedilink source parent hideshow 2 child comments replies: [+] __nobodynowhere@sh.itjust.works 1 point 1 year ago [deleted] permalink fedilink source parent [–] dragonlobster@programming.dev 2 points 1 year ago He loves me, he loves me not permalink fedilink source parent [–] vandsjov@feddit.dk 1 point 1 year ago No, no, I would convert the number to a string and just check the last char to see if it was even or not. permalink fedilink source parent
[–] OddMinus1@sh.itjust.works 3 points 1 year ago* (1 child) Could also be done recursive, I guess? boolean isEven(int n) { if (n == 0) { return true; } else { return !isEven(Math.abs(n - 1)); } } permalink fedilink source parent hideshow 2 child comments replies: [+] __nobodynowhere@sh.itjust.works 1 point 1 year ago [deleted] permalink fedilink source parent
[–] dragonlobster@programming.dev 2 points 1 year ago He loves me, he loves me not permalink fedilink source parent
[–] vandsjov@feddit.dk 1 point 1 year ago No, no, I would convert the number to a string and just check the last char to see if it was even or not. permalink fedilink source parent