# confused base case(s)

• 06-29-2005
tgtgtg
confused base case(s)
I understand that each recusive function must have one base case(A solution given directly) however they may also have two. This is where I get confused see below. Is my thinking below correct or way off?

Code:

```int funct1(int m, int n) {     if (m==n || n==1)          //  single base case              return 1;     else           return funct1(m-1,n-1) + n*func1(m-1, n); }```
if I broke these in two parts as below I would have two base cases. I think it still says the same as (this |or| that) Am I on the right track.

Code:

``` int ...................         if (m==n)                 return 1              //1st base case         else if (n==1)                 return 1                // 2nd base case         else                   .........................```
• 06-29-2005
mitakeet
Logically your two constructs are exactly the same.

A recursive function must have at least one return to break the recursion, it can have any number >= 1.
• 06-29-2005
tgtgtg
Thanks,
I thought they were saying the same thing. To have two base cases one of the returns would have to be something other than 1?
• 06-29-2005
swoopy
I don't think it matters whether you write it as:
Code:

```    if (m==n || n==1)         return 1;```
Or:
Code:

```        if (m==n)                 return 1;            //1st base case         else if (n==1)                 return 1;              // 2nd base case```
It's still two base cases. With the first example, you just combined the two base cases into one statement. Someone correct me if I'm wrong.
• 06-29-2005