Professor Nitwit obtains a hash number of a given positive integer greater…

2024

Professor Nitwit obtains a hash number of a given positive integer greater than 3 as follows. He subtracts 2 from the number (to get the new number), and multiplies the new number by 2 to get a term. He repeats this with the new number (to get newer numbers and terms) until the number becomes 2 or 1. The hash is defined as the sum of all the numbers generated in the process.

For example, with the number 5, he multiplies (5 - 2 = 3) by 2 to get the first term 6. He multiplies (3 - 2 = 1) by 2 to get the second term 2. As the number has become 1, he stops. The hash is the sum of the two numbers (6 + 2) = 8.

If Professor Nitwit is given 3 numbers 4, 9 and 13, what is the sum of the hash numbers he obtains for the three numbers?

Answer: D. 108Repeatedly subtracting a fixed number 2 from a value generates numbers in an arithmetic progression (AP) with common difference 2. Professor Nitwit's hash…

  1. A.

    250

  2. B.

    150

  3. C.

    200

  4. D.

    108

Attempted by 41 students.

Show answer & explanation

Correct answer: D

Repeatedly subtracting a fixed number 2 from a value generates numbers in an arithmetic progression (AP) with common difference 2. Professor Nitwit's hash number for an input n is twice the sum of this AP: hash(n) = 2 x (sum of n-2, n-4, n-6, ... down to the last positive term before the process stops at 1 or 2).

  1. For n = 4: the process gives (4 - 2) = 2, and it stops immediately since 2 is a stopping value. Sum of this one-term AP = 2, so hash(4) = 2 x 2 = 4.

  2. For n = 9: the process gives 7, 5, 3, 1 (it stops at 1). Sum of this AP = 7 + 5 + 3 + 1 = 16, so hash(9) = 2 x 16 = 32.

  3. For n = 13: the process gives 11, 9, 7, 5, 3, 1 (it stops at 1). Sum of this AP = 11 + 9 + 7 + 5 + 3 + 1 = 36, so hash(13) = 2 x 36 = 72.

Cross-check with the worked example already given in the question: for n = 5, the process gives 3, 1, so hash(5) = 2 x (3 + 1) = 8, exactly matching the stem and confirming the method.

Adding the three hash numbers: hash(4) + hash(9) + hash(13) = 4 + 32 + 72 = 108.

Explore the full course: Tcs Nqt Preparation

Loading lesson…