Vahagn_Grigoryan's blog

By Vahagn_Grigoryan, history, 4 weeks ago, In English

Hi, Codeforces Community!

I recently looked to a programm written by a participant in the contest, and I noticed this function, which is finding the greatest common devisor of two numbers.

long long int gcd(long long int a, long long int b) { return (b == 0LL ? a : gcd(b, a % b)); }

But I don't understand how this part (b == 0LL ? a : gcd(b, a % b)) of the function is working. Can anyone explain please?

 
 
 
 
  • Vote: I like it
  • +1
  • Vote: I do not like it

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by Vahagn_Grigoryan (previous revision, new revision, compare).

»
4 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it