IsEven(1000000000)
Technically correct. Also a speedrun to stack overflow
Some languages will optimize the tail recursion, but not python.
Inside the else
block, you could nest another if/else statement to check if the number is less than 0 and if it is, return isEven(num+2)
, else return isEven(num-2)
.
Somebody must’ve screenshotted another PirateSoftware project.
Old post.
Why are we going back to this?
Did you just UperCamelCase a Python function?
I finally understand recursion.
Almost there. Just needs some memoization!
may i interest you in other ways to find if a number is even? https://github.com/desaleo/is-even
isEven(-8)
Uh? What do you mean that's not how it works?
We just wait out for the overflow
Python 3 ints don't overflow, they just allocate more ram.
What happens if you run out of ram?
then it's odd, or even, it depends on host system
swap
we autoscale machines with more ram and keep going!
Kein Problem. Einfach auf den swap auslagern oder das Programm mit dem Hinweis pausieren das mehr RAM nachgerüstet werden muss. Wenn der swap ausgeht, wird einfach auf die Cloud umgestiegen.
just download more RAM