NormR1
Posting Expert
Moderator
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
class GCD
{
int gcd(int m,int n)
{
if(n==0)
return m;
else if(n>m)
return gcd(n,m);
else
return gcd(n,m%n);
}
public static void main(String[] args)
{
int num1=Integer.parseInt(args[0]);
int num2=Integer.parseInt(args[1]);
GCD obj=new GCD();
System.out.println("GCD of "+num1+" and "+num2+" is "+obj.GCD(num1,num2));
}
}