Skip to content
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
30 changes: 30 additions & 0 deletions Math/Modular Arithmetic/C++/modular-arithmetic.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <iostream>
using namespace std;
#define PRIME 1000000007 // Prime Number

long long int factorial(long long int n)
{
if(n==1||n==0){ // the factorial of 1 and 0 is 1
return 1;
} else {
return ((n % PRIME) * (factorial(n - 1) % PRIME)) % PRIME;
}
}

int main()
{
long long int x, y;

cin>>x>>y;

x = factorial(x);

y = factorial(y);


long long int answer = (x + y) % PRIME;

cout<<answer<<endl;

return 0;
}