使用函数可以通过y排除多少次x
因此,基本上,我必须构建一种算法,该算法告诉我X可以被Y排除多少次。如果它不可分割,则应返回print -1。
这是我到目前为止的:
def divisible(x, y):
n = int(x/y)
if (n != 0 and x%y == 0):
print(x, "its divisible by",y,n,"times")
else:
print(-1)
divisible(5, 2)
练习要求使用柜台做到这一点。我该怎么做?
谢谢
So, basically I have to built an algorithm that tells me how many times X is divisible by Y. If its not divisible, it should return print -1.
Here's what i've got so far:
def divisible(x, y):
n = int(x/y)
if (n != 0 and x%y == 0):
print(x, "its divisible by",y,n,"times")
else:
print(-1)
divisible(5, 2)
The exercise its asking to use a counter to do this. How can I make It?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
整数部门和Modulo功能应该使您到达那里 -
Integer division and the modulo function should get you there -