# Bell number calculation [closed]

Sorry if this forum is not relevant for programming question, but please if possible help me. I have the following code to calculate the Bell number:

#include <iostream>
using namespace std;
int bell(int n,int m){
if (n==1 && m==1)  return 1;
if (n >1 & m==1)  return  bell(n-1,n-1);
if (n>1  && (1< m && m<=n) )
return  bell(n-1,m-1)+bell(n,m-1);

}
int main(){

return 0;
}


It shows me the following error

Line 9: warning: control reaches end of non-void function


Please help. Thanks a lot.

-

## closed as off topic by Yuval Filmus, t.b., Gerry Myerson, Zev ChonolesDec 13 '11 at 3:58

Questions on Mathematics Stack Exchange are expected to relate to math within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here. If this question can be reworded to fit the rules in the help center, please edit the question.

Where did you get this? –  Guess who it is. Sep 3 '11 at 12:05
here cargalmathbooks.com/5%20Recursive%20Algorithms.pdf please see –  dato datuashvili Sep 3 '11 at 12:09

## 2 Answers

The reason why that error occurs is because you do not have an else statement with a return in it, it is a standard compiler warning.

As your compiler does not know what the values of m and n are going to be at compile time, it does not know whether one of the if tests will succeed and cause a return. Therefore, it thinks that it is possible that it can happen that your function just simply does not return anything in some cases.

-

Consider what happens if $n \leq 0$ or $m \leq 0$.

-