Skip to main content
1 of 7
flawr
  • 44.1k
  • 7
  • 109
  • 253

Haskell, 65 bytes

Golfing in process...

f n m e|e/n/m>1000=0|n>m=1+f(n-m)m e|n<m=f m n e g n m=f n m(n*m) 

Try it online!

flawr
  • 44.1k
  • 7
  • 109
  • 253