Remainder Evaluation | Practice | GeeksforGeeks

Given two positive integers num1 and num2, the task is to find the remainder when num1 is divided by num2.
Example 1:
Input:
num1 = 5
num2 = 3

Output:
2

Explanation:
The remainder after dividing 5 by 3 is: 2.
Example 2:
Input:
num1 = 5
num2 = 10

Output:
5

Explanation:
5 cannot be divided by 10 so it is 
the Remainder.

Your Task:  
You don't need to read input or print anything. Your task is to complete the function findRemainder() which takes two integer num1 and num2 as an input parameter and return the remainder when num1 is divided by num2.
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
Constraints:
0 <= num1 <= 106
1 <= num2 <= 106
0
akashmarkad22105 days ago
JAVA Solution 
 
static int findRemainder(int num1,int num2){       // code here              return num1%num2;   }
+1
nallalasumanthreddy3 weeks ago
UPVOTE PYTHON SOLUTION
class Solution:
    def findRemainder(self, num1, num2):
    	return num1%num2
+1
sakshamraj2292 months ago
class Solution
{
public:
   int findRemainder(int num1,int num2)
   {
       return num1%num2;
   }
};
0
abythankachan3143 months ago
Python code:
def findRemainder(self,number,num2):
    return num1%num2
0
avinashkhamanekar7693 months ago
class Solution:      def findRemainder(self, num1, num2):       if num1>num2:           remainder=0           remainder=num1%num2           print("The remainder after dividing",num1,"by",num2,"is :",remainder)       elif num1==num2:           remainder=0           print(remainder)       else:           print(num1,"canot be divided by ",num2)r=Solution()r.findRemainder(5,3) 
0
swatinegi4063 months ago
// In Java
class Solution{   static int findRemainder(int num1,int num2){       return num1%num2;   }}
+1
shreyanshikunda3 months ago
PYTHON SOLUTION
 def findRemainder(self, num1, num2):       C=num1%num2       return C    #code here 
0
arvindashlar3 months ago
#include<iostream>
using namespace std;
int main()
{
    int a, int b;
    cin>> a>>b;
    int c = a%b;
    cout<< c;
    return 0;
}
0
kaybesky893 months ago
// { Driver Code Starts   int findRemainder(int num1,int num2)   {       if(num1>num2)       {           return num1%num2;       }       else       {           return num1;       }   } 
0
mj80435593 months ago
#include <bits stdc++.h="">using namespace std;
int main() {int t;cin>>t;while(t!=0){int n1,n2,r;cin>>n1;cin>>n2;if(n1>n2){r=n1%n2;cout<<r<<endl;} else{cout<<n1<<endl;}="" t--;}="" code="" return="" 0;="" }="">
 
We strongly recommend solving this problem on your own before viewing its editorial. Do you still
                    want to view the editorial?
 Login to access your submissions. 

Problem


Contest

Reset the IDE using the second button on the top right corner.
Avoid using static/global variables in your code as your code is tested against multiple test cases and these tend to retain their previous values.
Passing the Sample/Custom Test cases does not guarantee the correctness of code. On submission, your code is tested against multiple test cases consisting of all possible corner cases and stress constraints.
You can access the hints to get an idea about what is expected of you as well as the final solution code.
You can view the solutions submitted by other users from the submission tab.