VOOZH about

URL: https://www.geeksforgeeks.org/dsa/sum-of-two-numbers-modulo-m/

⇱ Sum of two numbers modulo M - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Sum of two numbers modulo M

Last Updated : 13 Mar, 2023

Given three numbers A, B, and M. The task is to print the sum of A and B under modulo M

Examples

Input: a = 10, b = 20, m = 3 
Output: 0
Explanation: (10 + 20) % 3 = 30 % 3 = 0

Input: a = 100, b = 13, m = 107 
Output: 6

Approach: To solve the problem follow the below idea:

Add the two given numbers A and B and print their sum under modulo M.

Below is the implementation of the above approach:  


Output
0

Time complexity: O(1)
Auxiliary Space: O(1) 

Comment
Article Tags:
Article Tags: