In combinatorial mathematics, the Lobb number Lm, n counts the number of ways that n + m open parentheses can be arranged to form the start of a valid sequence of balanced parentheses.
The Lobb number are parameterized by two-negative integers m and n with n >= m >= 0. It can be obtained by:

Lobb Number is also used to count the number of ways in which n + m copies of the value +1 and n – m copies of the value -1 may be arranged into a sequence such that all of the partial sums of the sequence are non- negative.
Examples:
Input : n = 3, m = 2 Output : 5 Input : n =5, m =3 Output :35
The idea is simple, we use a function that computes binomial coefficients for given values. Using this function and above formula, we can compute Lobb numbers.
// CPP Program to find Ln, m Lobb Number.
#include <bits/stdc++.h>
#define MAXN 109
using namespace std;
// Returns value of Binomial Coefficient C(n, k)
int binomialCoeff(int n, int k)
{
int C[n + 1][k + 1];
// Calculate value of Binomial Coefficient in
// bottom up manner
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= min(i, k); j++) {
// Base Cases
if (j == 0 || j == i)
C[i][j] = 1;
// Calculate value using previously stored values
else
C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
}
}
return C[n][k];
}
// Return the Lm, n Lobb Number.
int lobb(int n, int m)
{
return ((2 * m + 1) * binomialCoeff(2 * n, m + n)) / (m + n + 1);
}
// Driven Program
int main()
{
int n = 5, m = 3;
cout << lobb(n, m) << endl;
return 0;
}
Output:
5
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

