[Procession Programmer](https://www.amazon.co.jp/%E8%A1%8C%E5%88%97%E3%83%97%E3%83%AD%E3%82%B0%E3% 83% A9% E3% 83% 9E% E3% 83% BC-% E2% 80% 95 Python% E3% 83% 97% E3% 83% AD% E3% 82% B0% E3% 83% A9% E3% 83 % A0% E3% 81% A7% E5% AD% A6% E3% 81% B6% E7% B7% 9A% E5% BD% A2% E4% BB% A3% E6% 95% B0-Philip-N-Klein / dp / 4873117771) p.19
Use Python to find the remainder of 2304811 divided by 47. However, do not use%.
How do you do it without using%! ?? I was addicted to it, so I made a note.
answer.py
2304811 - (2304811 // 47) * 47
Python has an operator called //, which is called truncation division.
sample.py
print(10 / 3) # 3.33333333333333
print(10 // 3) # 3
print(10 // 3.3) # 3.0
print(10 % 3.3) # 0.10000000000000053
print(10 // 3.4) # 2.0
print(10 // 3.33) # 3.0
For humans who entered from C, if you divide an integer value by an integer value, it will be rounded down and divided. I thought, but in a world without a mold, it seems that it will not go that way.
Recommended Posts