-
March 13th, 2013, 11:27 AM
#1
Begginer with Methods
Hey, i have a question involving methods. This program is supposed to take the largest common multiple from 2 numbers. I have no clue if i am on the right track but the main thing i need to know is how to get it to output the number that I get from the "public static int lcm".
public class TestLCM
{
public static void main(String[] args)
{
lcm(6, 8);
}
public static int lcm (int number1, int number2)
{
int iAdd1 = number1;
int iAdd2 = number2;
for (int iLoop = 1; iLoop <= 100; iLoop++)
{
number1= number1 + iAdd1;
number2= number2 + iAdd2;
if (number1 == number2) break;
}
return number1;
}
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|