C#趣味程序---爱因斯坦的台阶问题

问题:设有一阶梯,每步跨2阶。最后余1阶。每步跨3阶。最后余2阶;每步跨5阶。最后余4阶;每步跨6阶。最后余5阶;每步跨7阶。刚好到阶顶。问共同拥有多少阶梯?

using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int i = 1;
            while (!((i % 2 == 1) && (i % 3 == 2) && (i % 5 == 4) && (i % 6 == 5) && (i % 7 == 0)))
            {
                i++;
            }
            Console.WriteLine(i);
        }
    }
}

答案:119

posted @ 2017-04-21 10:22  yangykaifa  阅读(754)  评论(0)    收藏  举报