• Ebber@lemmings.world
    link
    fedilink
    arrow-up
    11
    ·
    2 days ago

    I removed the tail recursion for you:

    private book IsEven(int number) {
        if(number > 1) return IsEven(number - 2) == true;
        if(number == 0) return true; 
        if(number == 2) return false;
    }
    
    • ulterno@programming.dev
      link
      fedilink
      English
      arrow-up
      2
      ·
      2 days ago

      I didn’t get this.

      Why return book? Does that have some Blizzard reference?
      And why would number == 2return false? This is a function for getting true when the number is even, right?

      • Ebber@lemmings.world
        link
        fedilink
        arrow-up
        10
        ·
        edit-2
        2 days ago

        Haha, you’re right. I’ve now learned two things:

        1. I should not write code on a mobile
        2. I should not become a proof reader

        At the end of the day i just wanted the function to be worse, by causing stack overflows