Over a million developers have joined DZone.

GCD Of Two Numbers.

DZone's Guide to

GCD Of Two Numbers.

· ·
Free Resource
// finds GCD of a and b using Euclidian algorithm

public int GCD(int a, int b)
   if (b==0) return a;
   return GCD(b,a%b);

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}