Find Digits
All topics
Div Mod
The modulo operation is one of the most primitive things along with arithmetic operations on integers.
or is the remainder when is divided by .
if it means m divides a such that for some multiple k,
Some of the properties are
This operation is very useful when computation involves very large numbers and to check correctness we usually perform computation under modulo operation, hence keeping variables in standard integer size limits.
Modulo operation is also useful useful in the following:
- Chinese Remainder Theorm
- Fast Modulo exponentiation
- Inverse modulo operation
Integer to Array
You are given an integer and you want to perform operations on its digits. In modern scripting languages it can just be done by converting it to a string and then putting the characters into a list.
In order to do this efficiently, we can take all the digits and place them in an array.
arr[100] = {0};
i = 0
while ( n != 0) {
arr[i] = n%10;
n /= 10;
i++;
}
This way contains all the digits of integer .