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

Answer by Alexei Kopylov for Implement division using only addition

$
0
0

Haskell 0 additions, 29 bytes

n/m=[i|i<-[0..],_<-[1..m]]!!n

this redefines the division operator (/). it works by making a list of 0 to infinity where each item is repeated m times, and then choosing the nth element of the list (using a 0-based index).


Viewing all articles
Browse latest Browse all 18

Trending Articles



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