123
etrock
6y

Auuuuu 😢

Comments
  • 9
    Oh MY GOD !
  • 16
    return x%2 == 0
  • 34
  • 7
    @henlo That works? Man... I should learn about binary operations
  • 24
    def is_even(x):
    return not is_odd(x)

    def is_odd(x):
    return not_is_even(x)
  • 7
    @lazyDev u want so see the word burn huh?
  • 3
    @Marl3x c++ bit wise shit. This expression is true if x is odd
  • 12
  • 2
    My eyes hurt D:
  • 4
    MY EYES, MY EYES !!
  • 3
    is_even(MAX_INT) // discard return value because idc
  • 2
    Wtf? 😂
  • 4
    Hurray co-recursion?
  • 5
    error message received when
    x > 498:

    RecursionError: maximum recursion depth exceeded in comparison

    I'm actually somewhat surprised at how fast this is, despite how absolutely terrible it is. The default python recursion depth limit is triggered after x=498 so these functions are kinda useless... unless you know for sure no one would ever try a number larger than 498.
  • 1
  • 2
    @corscheid its useless anyway because you can literally do %2
  • 6
    @Supersebi3
    `(x&1)==0` is still the fastest. No division, only a single AND and CMP.

    Though it's python so it's all interpreted anyway; who knows what instructions the code actually maps to. I really kind of hate interpreted languages because of this.
  • 0
    @Root doesnt really matter for my point but ok
  • 3
    @Supersebi3 If you're going to do something, do it well. 😋
  • 1
    wot in tarnation
  • 0
    That is a nice (useless) demo to show recursion, although is_even wouldn't need to call is_odd.

    However, if all calls would be using constants, a C++ recursive template would be fastest:
    The compiler would do the math, and would substitute all calls with the results.
    That's called TMP.
    C++ rocks! 😁
Add Comment