Modular arithmetic Flashcards

1
Q

What is 72%7 ?

A

2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is -19%8 ?

A

5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is range of a%m?

A

[0, m-1]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is -60%9 in python ?

A

3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is -60%9 in c/c++/java/js/c# ?

A

-6 (In case of these language to calculate correct a%m add m to the answer so -6+9 = 3(correct ans))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Why do we need modular arithmetic?

A

It’s is used is concepts like consistent hashing, hash table, encryption etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

True or False

((a+b)%m) == (a%m + b%m)

A

False eg. (7+7)%4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

True or False

((a+b)%m) == (a%m + b%m)%m

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

True or False

(a*b)%m == ((a%m)*(b*m))%m

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Which number is divisible by 3?
* 4351
* 3521
* 7326
* 8236

A

7326
*sum of all digits should be divisible by 3.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Which number is dvisible by 4?
* 42234
* 64262
* 87118
* 43256

A

43256
*Last two digit should be divisible by 4.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is 534259%3 ?

A

1
*(Sum of all the digits)%3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is 63493%4 ?

A

1
*(Last two digits) % 4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

A number is divisible by 8 if….

A

A number is divisible by 8 if its last three digits are divisible by 8.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

A number is divisible by 6 if…

A

A number is divisible by 6 if it is divisible by 2 and 3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

A number is divisible by 9 if…

A

A number is divisible by 9 if its digits add up to a number divisible by 9

17
Q

A number is divisible by 7 if…

A

if a number is divisible 7, then the difference between twice the unit digit of the given number and the remaining part of the given number should be equal to 0, or the multiples of 7.

18
Q

What is Reminder in following statement?
~~~
Dividend = Divisor x Quotient + Remainder.
~~~

A

Reminder = Dividend - num;
*num = Largest mulitple of divisor <= Dividend

19
Q

How to use power function in java?

A

Math.pow(a, b)

20
Q

What is return type of Math.pow() in Java?

A

Double