Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 9532 / 5,000 = 1.9064
- $ irb
- irb(main):001:0> x = 9532 # 今払いたいお金が変数 x に代入されているとします。
- => 9532
- irb(main):002:0> n5000 = x / 5000 # 5000 円札何枚まで払えるかは、整数として割り算をすれば分かります。ここでは変数 n5000 に代入してみます。
- => 1
- irb(main):003:0> x = x - 5000 * n5000 # 残金は、上で求めた枚数分の金額を引けば分かります。
- => 4532
Add Comment
Please, Sign In to add comment