Data Structures & AlgorithmsHardGATE CS · Codeforces Div2 B

How many integers i with 1 <= i <= 50 have i * i mod 10 = 9?

  1. A. 20
  2. B. 10
  3. C. 5
  4. D. 25

Correct answer: B. 10

Squares end in 9 only for last digits 3 and 7 (9 and 49), and each last digit appears 5 times in 1–50, so 10. Counting only last digit 3 gives 5, counting last digits 1, 3, 7, 9 (squares ending in 1 or 9) gives 20 and 25 counts all odd numbers.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic