Data Structures & AlgorithmsModerateICPC regional · Amazon SDE OA

How many integers n from 1 to 99 inclusive have both n and n + 1 squarefree (not divisible by any square greater than 1)?

  1. A. 34
  2. B. 61
  3. C. 33
  4. D. 90

Correct answer: C. 33

Check squarefreeness by testing divisibility by square factors d^2 up to sqrt(n). Pairs of consecutive numbers are tested directly over the range.

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

Exams that ask this topic