This has been around a while, but might interest some of you. It is slower than those mentioned earlier, but it does not have a loop, nor any ^:

div=: 4 : 0
p=.x(>:@-&#)y
p({.;}.)x%.|:((p,#x)$y,p$0),(=/ (-#x)&{.)~}.i.#y
)

x is divided by y, quotient and remainder in boxes. Can be written in several ways.

Ralph Selfridge
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to