Biology Forums - Study Force

Science-Related Homework Help Computer Studies Topic started by: DePeet on Apr 30, 2018



Title: Consider the following recursive sum method:public int sum(int x){if (x == 0) return 0;else return ...
Post by: DePeet on Apr 30, 2018
Consider the following recursive sum method:
   public int sum(int x)
   {
      if (x == 0) return 0;
      else return sum(x - 1) + 1;
   }
If the base case is replaced with if (x == 1) return 1; the method will still compute the same thing.


Title: Re: Consider the following recursive sum method:public int sum(int x){if (x == 0) return 0;else ...
Post by: Stinger on Apr 30, 2018
Content hidden