Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lobb Number in C++ #3081

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions Lobb_Number/Lobb_Number.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// 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, m;
cout << "Enter n and m\n";
cin >> n >> m;
cout << lobb(n, m) << endl;
return 0;
}

/*Output

Enter n and m
5 3
35*/