Divide Int to Int and return Int

前端 未结 2 1362
清歌不尽
清歌不尽 2021-02-02 05:13

I need a function which gets two Ints (a and b) and returns A/B as Int. I am sure that A/B will alw

相关标签:
2条回答
  • 2021-02-02 05:23

    Here's what I did to make my own:

    quot' a b
             | a<b = 0  -- base case
             | otherwise = 1 + quot' a-b b
    
    0 讨论(0)
  • 2021-02-02 05:33

    Why not just use quot?

    quot a b
    

    is the integer quotient of integers a and b truncated towards zero.

    0 讨论(0)
提交回复
热议问题