Quantcast
Channel: Implement division using only addition - Code Golf Stack Exchange
Viewing all articles
Browse latest Browse all 18

Answer by Cary Swoveland for Implement division using only addition

$
0
0

In Ruby,

def divide(a,b)  n, d = 'x' * a, 'x' * b  l = []  (l << 'x'; d << 'x' * b) while n.size >= d.size  l.sizeend  

I don't know TCL, but I suspect this is the same approach as @Johannes ' (first) answer.


Viewing all articles
Browse latest Browse all 18

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>