愛因斯坦曾經提出過這樣一道有趣的數學題:有一個長階梯,若每步上2階,最後剩下1階;若每步上3階,最後剩2階;若每步上5階,最後剩下4階;若每步上6階,最後剩5階;只有每步上7階,最後剛好一階也不剩。請問該階梯至少有多少階
int i = 7;
int times = 1000;
while ((i % 2 != 1 || i % 3 != 2 || i % 5 != 4 || i % 6 != 5) && i < times) {
i += 7;
}
if (i > times)
printf("The no result of Einstein's question \n");
else
printf("The result of Einstein's question is %d\n", i);
結果: