ProgrammingHardTCS NQT · Infosys
Using square-and-multiply on int values with a reduction modulo 1000 after each multiplication, what is 3^13 mod 1000?
- A. 594
- B. 1
- C. 369
- D. 323
Correct answer: D. 323
3^13 = 1594323, and reducing modulo 1000 gives 323. Reducing after each multiplication gives the same residue and keeps values small.
More C Programming questions
- How many 6-bit masks have exactly two 1 bits and have bit 0 cleared?
- The binary-reflected Gray code of i is g(i) = i ^ (i >> 1). What is g(4)?
- What is popcount(0xFFFF0000 ^ 0x0F0F0F0F)?
- int q = NULL; if (q != NULL && q == 3) printf("yes"); else printf("no"); What is printed?
- #define ADD(a,b) a+b. What does printf("%d", 2 ADD(1,2) 3) print?
- #define HALF(x) x / 2. With int a = 5, b = 3, what does printf("%d", HALF(a + b)) print?