如何在python中运行模数?

时间:2018-02-12 06:08:24

标签: python modulo

为什么 -4%5 => 1 //I understand -5%5 => 0 //I understand -6%5 => 4 // My mind has been deleted

我在c / cpp中检查过,结果只有-1。

1 个答案:

答案 0 :(得分:1)

-6:最小数字小于或等于-6并且可以被5整除-10

# just like the other examples
-4 - (-5) == 1  
-5 - (-5) == 0  
-6 - (-10) == 4  # fits perfectly in there
-7 - (-10) == 3  
-8 - (-10) == 2