Stopwatch();
            l_cc_stopWatch.Start();

            Random rad = new Random();
            
while (true)
            {
                
string ts = string.Empty;
                
while (ts.Length < 9)
                {
                    
string tmp = rad.Next(110).ToString();
                    
if (ts.IndexOf(tmp) < 0)
                    {
                        ts 
+= tmp;  //得到9位不重複數
                    }
                }
                
bool flag = false;
                
for (int m = 2; m <= 9; m++)
                {
                    
if (Int32.Parse(ts.Substring(0, m)) % m == 0)  //前n位能被n整除
                    {
                        flag 
= true;
                    }
                    
else
                    {
                        flag 
= false;
                    }

                    
if (flag == false)
                    {
                        
break;
                    }
                }

                
if (flag)
                {
                    Console.WriteLine(ts);
                    
break;
                }
            }

            l_cc_stopWatch.Stop();
            Console.WriteLine(
"{0}:seconds", l_cc_stopWatch.Elapsed.TotalSeconds);

相关文章:

  • 2022-01-30
  • 2022-12-23
  • 2022-01-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-18
猜你喜欢
  • 2021-10-17
  • 2021-11-11
  • 2022-12-23
  • 2022-12-23
  • 2021-07-07
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案