//finding gcd
class gcd
{ public static void main(String args[])
{
int n1,n2,sn,i;
n1=Integer.parseInt(args[0]);
n2=Integer.parseInt(args[1]);
if ( n1 < n2 )
sn = n1;
else
sn = n2;
for ( i=sn ; i>=1;i --)
if( n1%i==0 && n2 %i==0)
break;
if(i==1)
System.out.println("No
GCD");
else
System.out.println("GCD is
" + i);
}
}
Compile တဲ့အခါ မွာ
javac gcd.java
Run တဲ့အခါ မွာ
java gcd 24 36
No comments:
Post a Comment