码迷,mamicode.com
首页 > 其他好文 > 详细

取鸡蛋问题

时间:2016-11-21 14:58:01      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:log   多少   code   int   style   sof   mic   python   div   

求鸡蛋总数

一筐鸡蛋,1个1个拿,刚好拿完;2个2个拿,剩下1个;3个3个拿,剩下1个;4个4个拿,剩下1个,5个5个拿,剩下1个;6个6个拿,剩下1个;7个7个拿,刚好拿完;问这筐鸡蛋有多少?

 

问题解决

这里我们使用Python3进行求解。

# 求鸡蛋总数
x = 1
while(x<10000):
        x += 1
        if(x%2==1 and x%3==1 and x%4==1 and x%5==1 and x%6==1 and x%7==0):
                break
print("x =",x)

 结果:

x = 301

 

取鸡蛋问题

标签:log   多少   code   int   style   sof   mic   python   div   

原文地址:http://www.cnblogs.com/changyou7/p/6078607.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!