Divide a number using only addition and subtraction.
Anonymous
func divide(var a:NSInteger, b:NSInteger) -> (answer:NSInteger, remainder:NSInteger){ var counter = 0 while(a>=b){ counter++ a-=b; } return (counter, a) }
Check out your Company Bowl for anonymous work chats.