Given a string str representing a large integer, the task is to find the result of N % 4.
Input: N = 81
Input: N = 46234624362346435768440
Approach: The remainder of division by 4 is dependent on only the last 2 digits of a number, so instead of dividing N we divide only the last two digits of N and find the remainder.
Below is the implementation of the above approach:
Time Complexity: O(1)
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Program to find remainder when large number is divided by 11
- Program to find remainder when large number is divided by r
- Remainder with 7 for large numbers
- Multiply large integers under large modulo
- Find the value of XXXX.....(N times) % M where N is large
- Program to find remainder without using modulo or % operator
- Find remainder of array multiplication divided by n
- Chinese Remainder Theorem | Set 2 (Inverse Modulo based Implementation)
- Using Chinese Remainder Theorem to Combine Modular equations
- Program for quotient and remainder of big number
- Generate Array whose sum of all K-size subarrays divided by N leaves remainder X
- Quotient - Remainder Sort
- Quotient Remainder Theorem
- Check if the remainder of N-1 factorial when divided by N is N-1 or not
- Find Last Digit of a^b for Large Numbers
- Find (a^b)%m where 'a' is very large
- Find (a^b)%m where 'b' is very large
- Find smallest possible Number from a given large Number with same count of digits
- Find all Factors of Large Perfect Square Natural Number in O(sqrt(sqrt(N))
- GCD of two numbers when one of them can be very large
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.