Question

A function f:N+→N+f : \mathbb{N}^+ \to \mathbb{N}^+, defined on the set of positive integers N+\mathbb{N}^+, satisfies the following properties:

f(n)=f(n/2)if n is evenf(n) = f(n/2) \quad \text{if } n \text{ is even}
f(n)=f(n+5)if n is oddf(n) = f(n + 5) \quad \text{if } n \text{ is odd}

Let R={i∣∃j:f(j)=i}R = \{i \mid \exists j : f(j) = i\} be the set of distinct values that ff takes. The maximum possible size of RR is _____.

Official answer and solution
Official answer
2
From
Official GATE 2016 answer key

Solution

Analyze the modular dynamics of n/2n/2 and n+5n+5 to partition positive integers into equivalence classes.

The function f:N+→N+f: \mathbb{N}^+ \to \mathbb{N}^+ satisfies:

  • f(n)=f(n/2)f(n) = f(n/2) if nn is even
  • f(n)=f(n+5)f(n) = f(n + 5) if nn is odd

Notice that if nn is odd, n+5n + 5 is even, so f(n)=f(n+5)=f((n+5)/2)f(n) = f(n+5) = f((n+5)/2).
Let us trace the operations on positive integers modulo 5:

  • If nn is a multiple of 5 (n=5kn = 5k):
    • For n=5n = 5: f(5)=f(10)=f(5)f(5) = f(10) = f(5) (forms a self-loop).
    • For any n=5kn = 5k: repeatedly applying n→n/2n \to n/2 when even and n→n+5n \to n+5 when odd preserves divisibility by 5 because adding 5 preserves multiples of 5, and dividing an even multiple of 5 by 2 yields another multiple of 5.
      All multiples of 5 eventually reduce to the attractor 5.

Now consider integers NOT divisible by 5 (n≢0(mod5)n \not\equiv 0 \pmod 5):

  • Adding 5 preserves n(mod5)n \pmod 5.
  • Dividing an even number by 2 multiplies by 2−1≡3(mod5)2^{-1} \equiv 3 \pmod 5, which never maps a non-zero residue to zero.
    Thus, no number not divisible by 5 can ever transition to a multiple of 5.

Trace values not divisible by 5:

  • n=1n = 1: f(1)=f(6)=f(3)f(1) = f(6) = f(3)
  • n=3n = 3: f(3)=f(8)=f(4)=f(2)=f(1)f(3) = f(8) = f(4) = f(2) = f(1)
  • n=7n = 7: f(7)=f(12)=f(6)=f(3)=f(1)f(7) = f(12) = f(6) = f(3) = f(1)
  • n=9n = 9: f(9)=f(14)=f(7)=f(1)f(9) = f(14) = f(7) = f(1)
    Every integer coprime to 5 is reachable from and reduces to the cycle {1,2,3,4,6,8}\{1, 2, 3, 4, 6, 8\}.

Therefore, the set of positive integers N+\mathbb{N}^+ is partitioned into exactly two disjoint connected components under the relations:

  1. The set of integers not divisible by 5 (all mapped to f(1)f(1))
  2. The set of integers divisible by 5 (all mapped to f(5)f(5))
    Since there are only 2 equivalence classes, ff can take at most 2 distinct values. Hence, the maximum possible size of RR is 2.
Final answer

2

Common trap

Assuming f(n)f(n) can produce an infinite range of values, missing that the collatz-like operations collapse all inputs into two closed cycles modulo 5.

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2016 Computer Science and Information Technology (CS) Session 1
Question
38 of 65, printed as CS Q.28
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.