Project Euler #5: Smallest multiple

  • + 0 comments

    C#

    static void Main(String[] args) {
            int t = Convert.ToInt32(Console.ReadLine());
            for(int a0 = 0; a0 < t; a0++){
                int n = Convert.ToInt32(Console.ReadLine());
                Test(n, t);
            }
            
        }
        
        public static void Test(int n, int t)
        {
            int rightNow = n;
            bool goOut = false;
            while (goOut is false)
            {
                for (int i=1; i<=n; i++)
                {
                    if (rightNow%i != 0)
                    {
                        rightNow++;
                        break;
                    }
                    
                    if (i == n)
                    {
                        goOut = true;
                    }
                }
            }
            
            Console.WriteLine(rightNow);
        }