首页 > Windows开发 > 详细

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

时间:2015-06-29 14:51:21      阅读:295      评论:0      收藏:0      [点我收藏+]

问题:设有一阶梯,每步跨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

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

原文:http://blog.csdn.net/lucky51222/article/details/46682029

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!