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
 
Related challenge for Div Mod
Go to Top

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 .

 
Related challenge for Integer to Array
Go to Top
  1. Challenge Walkthrough
    Let's walk through this sample challenge and explore the features of the code editor.1 of 6
  2. Review the problem statement
    Each challenge has a problem statement that includes sample inputs and outputs. Some challenges include additional information to help you out.2 of 6
  3. Choose a language
    Select the language you wish to use to solve this challenge.3 of 6
  4. Enter your code
    Code your solution in our custom editor or code in your own environment and upload your solution as a file.4 of 6
  5. Test your code
    You can compile your code and test it for errors and accuracy before submitting.5 of 6
  6. Submit to see results
    When you're ready, submit your solution! Remember, you can go back and refine your code anytime.6 of 6
  1. Check your score