# [Haskell], <s>71 70 65 63 62 61</s> 58 bytes Thanks to @xnor for a some improvements! <!-- language: lang-hs --> (n#m)e|e>n*m*1e3=0|n>=m=((n-m)#m)e+1|n<m=m#n$e n!m=n#m$n*m [Try it online!] [Haskell]: https://www.haskell.org/ [Try it online!]: https://tio.run/nexus/haskell#@6@Rp5yrmVqTapenlatlmGpsa1CTZ2eba6uhkaebqwmS0zasybPJtc1VzlNJ5cpTzLUF6lABqv6fm5iZp2CrUFBaElxS5JOnoKJQnJFfDqQ0DI1NFQ0NDDT/AwA "Haskell – TIO Nexus"