拿鸡蛋问题

题目:1个1个拿,正好拿完。2个2个拿,还剩1个。3个3个拿,正好拿完。

     4个4个拿,还剩一个。5个5个拿,还差1个。 6个6个拿,还剩3个。

     7个7个拿,正好拿完。8个8个拿,还剩1个。9个9个拿,真好拿完。

代码:

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 
 6 namespace eggs
 7 {
 8     class Program
 9     {
10         static void Main(string[] args)
11         {
12             //最少的鸡蛋个数
13             int n = 63;
14             while (true)
15             {
16                 if (n % 2 == 1 && n % 5 == 4 && n % 6 == 3 && n % 8 == 1)
17                 {
18                     Console.WriteLine(n);
19                     Console.ReadLine();
20 
21                 }
22                 n+=63;
23             }
24             
25             //第二少的鸡蛋个数
26             int i = 63, j = 0;
27             while (true)
28             {
29                 if (i % 2 == 1 && i % 5 == 4 && i % 6 == 3 && i % 8 == 1)
30                 {
31                     j++;
32                     if (j >= 2)
33                         break;
34                     
35                 }
36                 i += 63;
37             }
38             Console.WriteLine(i);
39             Console.ReadLine();
40             
41             //运行成功回车一次,显示下一个最少鸡蛋数
42 
43         }
44     }
45 }
原文地址:https://www.cnblogs.com/lixiaokang-blog/p/7606001.html