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