Computer Science EngineeringHard

What does g(48, 18) return for int g(int a,int b){ return b==0 ? a : g(b, a%b); }

  1. A. 6
  2. B. 12
  3. C. 3
  4. D. 18

Correct answer: A. 6

g(48,18)->g(18,12)->g(12,6)->g(6,0)=6, the gcd.

More Algorithms, Data Structures & Programming (ISRO CS) questions

Exams that ask this topic