## (java/math) how to find quotient in mod?

This may be a rather simple problem. I'll show an example.

I have *A* and *B* (take it as client and server set-up). *A* does the following
`(2^10) mod 23 = 12`

.

It then sends the value 12 over to *B*

Now, *B* has the equation `12 = (2^x) mod 23`

. (It has the modulus and the base value). How would I find the value 10? I tried inverse mod, but that seems to work only for a power of -1. Google doesn't seem to help much either. Just the math help would be great, but if there is a Java function for it, it would be even better.

**Program to find Quotient And Remainder in Java,** The remainder is the integer left over after dividing one integer by another. The quotient is the quantity produced by the division of two numbers. For example,. (7/2) In arithmetic, the remainder is the integer "left over" after dividing one integer by another to produce an integer quotient (integer division). Java Program To Find Quotient And Remainder Chapter: Math Class Last Updated: 25-08-2017 08:36:04 UTC

The property we can use to solve this is that *A* can only have 23 unique outputs. Therefore you can precalculate all the values that you might pass into the left hand side of *B*, and record the inputs that get those values, until you get a full list:

2^0 % 23 == 1 2^1 % 23 == 2 2^2 % 23 == 4 2^3 % 23 == 8 2^4 % 23 == 16 2^5 % 23 == 9 2^6 % 23 == 18 2^7 % 23 == 13 2^8 % 23 == 3 2^9 % 23 == 6 2^10 % 23 == 12 . . .

You will find that after the 10th output, there is a repeating sequence of the above values, so those are the only values that *B* should take as input.

**Java Program to Compute Quotient and Remainder,** Now, to find the quotient we divide dividend by divisor using / operator. Since, both dividend and divisor are integers, the result will also be computed as an integer Find the first element of a Stream in Java Program to find Quotient And Remainder in Java The remainder is the integer left over after dividing one integer by another. The quotient is the quantity produced by the division of two numbers.

Sorry to add this:

Basically after certain loop due to `2^11 mod 23 = 1`

and `(a * b) mod c = (a mod c) * (b mod c) mod c`

, which is the mod multiplication rule.

So we can definitely use the `loop`

to get the final result using just a simple list (no matter how big the `i`

might be) as:

int getMod(int i) { int[] ret = new int {1, 2, 4, 8, 16, 9, 18, 13, 3, 6, 12}; return ret[i % 11]; }

To OP, there is a tutorial explaining well about the math solving program problems. Might it be helpful.

**The Modulo Operator in Java,** We can observe that we lose the remainder of a division operation when dividing integers. The modulo operator gives us exactly this remainder: ? Quotient = 6 Remainder = 1 In the above program, two numbers 25 (dividend) and 4 (divisor) are stored in two variables dividend and divisor respectively. Now, to find the quotient we divide dividend by divisor using / operator.

**How to find Quotient And Remainder in Java,** In this article, we will write a Java program to find Quotient and Remainder, when one number is divided by another number. Example: Program to find. Just if somebody goes over this question and wonders how you would get not the quotient, but the largest natural number <= the quotient or the mod you can use the function in the math package: Math.floorDiv(x,y) and Math.floorMod(x,y) – Frank Essenberger Aug 15 '16 at 7:28

**Java Program to Find Quotient and Remainder,** What is a Modulus operator in Java? The modulus operator returns the remainder of the two numbers after division. If you are provided with two 1. If you're going to compute the remainder rem anyway, you can get the quotient div faster without flooring: (y - rem) / x. 2. By the way the modulo operation by Donald Knuth's recommended definition (sign-matches-divisor, not the remainder i.e. Euclidean modulus, nor the JavaScript sign-matches-dividend) is what we can code in JavaScript as

**Modulus in Java | Remainder or Modulus Operator in Java,** The Remainder or Modulus Operator in Java surprising because you don't normally think of real number division as producing remainders. The Remainder or Modulus Operator in Java. Java has one important arithmetical operator you may not be familiar with, %, also known as the modulus or remainder operator. The % operator returns the remainder of two numbers. For instance 10 % 3 is 1 because 10 divided by 3 leaves a remainder of 1.