Ask Question
6 September, 07:14

How can I do trace table java for LCM?

+2
Answers (1)
  1. 6 September, 10:41
    0
    import java. util.*;

    import java. io.*;

    class Main {

    public static void main (String[] args) {

    int a, b, lcm1;

    System. out. println ("Enter two integers: ");

    Scanner s12=new Scanner (System. in);

    a = s12. nextInt ();

    b=s12. nextInt ();

    / / maximum number between n1 and n2 is stored in lcm

    lcm1 = (a > b) ? a : b;

    / / Always true

    while (true)

    {

    if (lcm1 % a = = 0 && lcm1 % b= = 0)

    {

    System. out. printf ("The Least common multiple of %d & %d is %d.", a, b, lcm1);

    break;

    }

    ++lcm1;

    }

    }

    }

    Explanation:

    You can find the LCM of two integers using the program in java written above in answer section.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “How can I do trace table java for LCM? ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers