Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8891319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:42:42+00:00 2026-06-14T22:42:42+00:00

I have the current coding which used to be a goto but I was

  • 0

I have the current coding which used to be a goto but I was told to not use goto anymore as it is frowned upon. I am having troubles changing it into for say a while loop. I am fairly new to C# and programming in general so some of this is completely new stuff to me. Any help would be appreciated. The actual question is input two numbers and find the lowest common multiple.

Here is the original with goto:

BOB:
    if (b < d)
    {                
        a++;
        myInt = myInt * a;
        b = myInt;
        myInt = myInt / a;

        if (b % myInt2 == 0)
        {
            Console.Write("{0} ", h);
            Console.ReadLine();
        }

    }
    if (d < b)
    {
        c++;
        myInt2 = myInt2 * c;
        d = myInt2;
        myInt2 = myInt2 / c;

        if (d % myInt == 0)
        {
            Console.Write("{0} ", t);
            Console.ReadLine();
        }
        else
        {
            goto BOB;
        }

    }
    else
    {
        goto BOB;
    }

   }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:42:44+00:00Added an answer on June 14, 2026 at 10:42 pm

    Try This:

    using System;
    
    public class FindLCM
    {
        public static int determineLCM(int a, int b)
        {
            int num1, num2;
            if (a > b)
            {
                num1 = a; num2 = b;
            }
            else
            {
                num1 = b; num2 = a;
            }
    
            for (int i = 1; i < num2; i++)
            {
                int mult = num1 * i;
                if (mult % num2 == 0)
                {
                    return mult;
                }
            }
            return num1 * num2;
        }
    
        public static void Main(String[] args)
        {
            int n1, n2;
    
            Console.WriteLine("Enter 2 numbers to find LCM");
    
            n1 = int.Parse(Console.ReadLine());
            n2 = int.Parse(Console.ReadLine());
    
            int result = determineLCM(n1, n2);
    
            Console.WriteLine("LCM of {0} and {1} is {2}",n1,n2,result);
            Console.Read();
        }
    }
    

    Output:

    Enter 2 numbers to find LCM
    8
    12
    LCM of 8 and 12 is 24
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have current a developed app which I am going to submit in just
We have this current database which we need to replace some tables by anther
I have the current PHP: $thisarray[] = #000; SetProfileField('usercss', $USER->id, implode(',',$thisarray)); Which writes #000
I have three current thoughts on how to do this: re-implement AuthenticationService, which uses
I've been coding for a while, but still consider myself a beginner. I use
I'm coding on a project which makes heavy use of curried objects and templates.
I have been searching for something which might help me to resolve our current
I'm building an application using Visual Studio 2010 in which I have to use
I have the current bundle reference working locally: Bundles.Reference(/Content/global.css); On the development site, this
I have the current time format returned from the web service: 2012-06-25T23:45:52.664Z I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.