# Multiplication Under Modulo

Sun Feb 06 2022 02:09:46 GMT+0000 (UTC)

```import java.util.*;
import java.lang.*;
import java.io.*;

class Solution
{
static long multiplicationUnderModulo(long a, long b)
{
long M = 1000000007;
return ((a%M)*(b%M))%M;
}
}

class GFG
{
public static void main(String args[])throws IOException
{

//taking testcases

while(t-- > 0)
{

//taking input a and b
long a = Long.parseLong(str);
long b = Long.parseLong(str);

//calling multiplicationUnderModulo() function
System.out.println(new Solution().multiplicationUnderModulo(a, b));
}
}
}```
content_copyCOPY

10. Multiplication Under Modulo You are given two numbers a and b. You need to find the multiplication of a and b under modulo M (M as 10^9+7). Example 1: Input: a = 92233720368547758 b = 92233720368547758 Output: 484266119 Explanation: Multiplication of a and b under modulo M will be 484266119. Example 2: Input: a = 1000000007 b = 1000000007 Output: 0 Explanation: Multiplication of a and b under modulo M is 0. Your Task: You don't need to read input or print anything. Your task is to complete the function multiplicationUnderModulo() that takes a and b as parameters and returns multiplication of a and b under modulo M. Expected Time Complexity: O(1) Expected Auxilliary Space: O(1) Constraints: 1 <= a,b <= 2^63 - 1

https://practice.geeksforgeeks.org/problems/multiplication-under-modulo/1/?track=DSASP-Mathematics&batchId=190