当前位置:首页 > Windows程序 > 正文

爱因斯坦的台阶问题

2021-05-24 Windows程序

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

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/70386.html