[Question]
  [
This challenge, while probably trivial in most "standard" languages, is addressed to those languages which are so esoteric, low-level, and/or difficult to use that are very rarely seen on this site. It should provide an interesting problem to solve, so this is your occasion to try that weird language you've read about!
### The task
Take two natural numbers `a` and `b` as input, and output two other numbers: the result of the integer division `a/b`, and the remainder of such division (`a%b`).
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"): shortest answer (in bytes), for each language, wins!
### Input/Output
* 0<=`a`<=255, 1<=`b`<=255. Each of your inputs (and outputs too) will fit in a single byte.
* You may choose any format you like for both input and output, as long as the two numbers are clearly distinguishable (e.g. no printing the two results together without a delimiter)
### Examples
```
a,b->division,remainder
5,7->0,5
5,1->5,0
18,4->4,2
255,25->10,5
```
**Note:** Builtins that return both the result of the division and the remainder are *forbidden*. At least show us how your language deals with applying two functions to the same arguments.
**Note 2:** As always, an explanation of how your code works is very welcome, even if it looks readable to you it may not be so for someone else!
---
## The Catalogue
The Stack Snippet at the bottom of this post generates the catalogue from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.
To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:
```
## Language Name, N bytes
```
where `N` is the size of your submission. If you improve your score, you *can* keep old scores in the headline, by striking them through. For instance:
```
## Ruby, <s>104</s> <s>101</s> 96 bytes
```
If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the *last* number in the header:
```
## Perl, 43 + 2 (-p flag) = 45 bytes
```
You can also make the language name a link which will then show up in the snippet:
```
## [><>](https://esolangs.org/wiki/Fish), 121 bytes
```
```
/* Configuration */
var QUESTION_ID = 114003; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 8478; // This should be the user ID of the challenge author.
/* App */
var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;
function answersUrl(index) {
  return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}
function commentUrl(index, answers) {
  return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}
function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}
function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });  
}
getAnswers();
var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;
var OVERRIDE_REG = /^Override\s*header:\s*/i;
function getAuthorName(a) {
  return a.owner.display_name;
}
function process() {
  var valid = [];
  
  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '<h1>' + c.body.replace(OVERRIDE_REG, '') + '</h1>';
    });
    
    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
      });
    else console.log(body);
  });
  
  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });
  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;
    
    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);
    var lang = a.language;
    lang = jQuery('<a>'+lang+'</a>').text();
    
    languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang, user: a.user, size: a.size, link: a.link};
  });
  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);
  langs.sort(function (a, b) {
    if (a.lang_raw.toLowerCase() > b.lang_raw.toLowerCase()) return 1;
    if (a.lang_raw.toLowerCase() < b.lang_raw.toLowerCase()) return -1;
    return 0;
  });
  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }
}
```
```
body {
  text-align: left !important;
  display: block !important;
}
#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}
#language-list {
  padding: 10px;
  width: 500px;
  float: left;
}
table thead {
  font-weight: bold;
}
table td {
  padding: 5px;
}
```
```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/codegolf/all.css?v=ffb5d0584c5f">
<div id="language-list">
  <h2>Shortest Solution by Language</h2>
  <table class="language-list">
    <thead>
      <tr><td>Language</td><td>User</td><td>Score</td></tr>
    </thead>
    <tbody id="languages">
    </tbody>
  </table>
</div>
<div id="answer-list">
  <h2>Leaderboard</h2>
  <table class="answer-list">
    <thead>
      <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr>
    </thead>
    <tbody id="answers">
    </tbody>
  </table>
</div>
<table style="display: none">
  <tbody id="answer-template">
    <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr>
  </tbody>
</table>
<table style="display: none">
  <tbody id="language-template">
    <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr>
  </tbody>
</table>
```
  
[Answer]
# [BitCycle](https://github.com/dloscutoff/Esolangs/tree/master/BitCycle), ~~146~~ ~~79~~ 64 bytes
*Just realized a whole section of my original code was unneccessary. Huge reduction!*
```
v  <>!
A\B^^=
? D^>^<
 >\v^~ D@
 >/ C/
  > C ^
A/B v
^   <
?  D^
```
The program takes input in unary from the command line, with the divisor first. It outputs the quotient and remainder in unary, separated by a `0`. For example, here's `a=11`, `b=4`, `a/b=2`, `a%b=3`:
```
C:\>python bitcycle.py divmod.btc 1111 11111111111
110111
```
### Ungolfed, in action
Here's my ungolfed version computing `a=3`, `b=5` with animation turned on (sorry about the glitchiness):
[![Divmod running in BitCycle](https://i.stack.imgur.com/TDukU.gif)](https://i.stack.imgur.com/TDukU.gif)
### Attempt at an explanation
*The explanation applies to the ungolfed version. Before you tackle it, I highly recommend you read the [Esolangs page](http://esolangs.org/wiki/BitCycle) to get a feel for how the language works.*
The algorithm goes like this:
* Run an outer loop until the program is terminated.
	+ Run an inner loop over the bits of the divisor, pairing them off with bits from the dividend.
		- If all bits of the divisor have matching dividend bits, output a single bit.
		- If not all bits of the divisor have matching dividend bits, output the separator `0` followed by what dividend bits there were, then terminate.
The heart of the code is the relationships among the collectors (the uppercase letters). Since there are multiple separate collectors with each letter, let's refer to them as `A1`, `A2`, `B1`, `B2`, etc., numbering from top to bottom.
* `A1` and `A2` hold the divisor and dividend, respectively, at the beginning of the main loop.
* The inner loop peels off one bit at a time from the divisor and the dividend.
	+ The rest of the divisor, if any, always goes into `B1`.
	+ If both the divisor and dividend were nonempty, one bit goes into `C1` and one into `C3`. The rest of the dividend goes into `B2`.
	+ If only the divisor was nonempty, we've reached the end of the dividend, and it's time to print the remainder. The bit from the divisor goes into `C2`.
	+ If only the dividend was nonempty, we've reached the end of the divisor; it's time to process the bits in `C3` or `C2` for output. The rest of the dividend goes into `C4`.
* If there are any bits in the `B` collectors, they cycle their contents back around to the `A` collectors and continue in the inner loop.
* Once the `A` and `B` collectors are all empty, the `C` collectors open and we proceed to the processing stage:
	+ `C1` and `C4` dump their contents (the divisor and the remaining dividend, respectively) into `D1` and `D3`.
	+ If `C2` is empty, we're still printing the quotient.
		- The contents of `C3` go up to the top right `=` switch. The first `1` bit passes straight through to `!` and is output.
		- When the `1` bit passes through, it activates the switch to point rightward, which sends all the subsequent bits off the board.
	+ If `C2` is not empty, we're printing the remainder.
		- The first bit of `C2` is negated to a `0` and passed through the switch. The `0` goes on to `!` and is output.
		- When the `0` bit passes through, it activates the switch to point leftward. Now all the bits from `C3` go leftward from the switch and are redirected around into the `!`, outputting the entire remainder.
		- A copy of the first bit from `C2` is also sent into `D2`.
* Now the `D` collectors open.
	+ If there is anything in `D2`, that means we just printed the remainder. The bit from `D2` hits the `@`, which terminates the program.
	+ Otherwise, the contents of `D1` and `D3` loop back into `A1` and `A2` respectively, and the main loop starts over.
[Answer]
# [brainfuck](https://github.com/TryItOnline/tio-transpilers), ~~43~~ 41 bytes
```
,<,[>->+<[>]>>>>+<<<[<+>-]<<[<]>-]>>.>>>.
```
This uses a modified version of my [destructive modulus algorithm on Esolangs](https://esolangs.org/wiki/Brainfuck_algorithms#Modulus_algorithm).
The program reads two bytes ‚Äì **d** and **n**, in that order ‚Äì from STDIN and prints two bytes ‚Äì **n%d** and **n/d**, in that order ‚Äì to STDOUT. It requires a brainfuck interpreter with a doubly infinite or circular tape, such as the one on TIO.
[Try it online!](https://tio.run/nexus/bash#TY5PC4JAEMXP@SkGMyz8R4JdWpYudgqKbqF7UHcXl8yVdSsPfXdbq0PDwJvf4z2YqtCAgYrHTdKw5IAQpMf96CM/wwH2UIYJNuMhhDLk4YBMSoxiHBo/HE3asjolWs3BWf4ON8@HxeCC7ezsFeTW7AWR7HSkhQy0Ktq@Ew1TfVSqQrT8Xl3/Pvikh4FC0PVf4LIxFH/hWZsqKFbQLVAJrKolONl6M3fO6elwIZPbsnGME7PJGw "Bash ‚Äì TIO Nexus")
### How it works
Before the program starts, all cells hold the value **0**. After reading **d** from STDIN (`,`), moving one step left (`<`) and reading **n** from STDIN (`,`), the tape looks as follows.
```
       v
A      B      C      D      E      F      G      H      J
0      n      d      0      0      0      0      0      0
```
Next, assuming that **n > 0**, we enter the while loop
```
[>->+<[>]>>>>+<<<[<+>-]<<[<]>-]
```
which transforms the tape as follows.
First, `>->+<` advances to cell **C** and decrements it, then advances to cell **D** and increments it, and finally goes back to cell **C**. What happens next depends on whether the value of cell **C** is zero or not.
* If cell **C** hold a positive value, `[>]` (go right while the cell is non-zero) will advance to cell **E**.
`>>>>+<<<` advances to cell **J** to increment it, then goes back to cell **F**.
Since cell **F** will always hold **0**, the while loop `[<+>-]` is skipped entirely, and `<<` goes back to cell **D**.
Finally, since neither **D** nor **C** hold **0**, `[<]` (go left while the cell is non-zero) will retrocede to cell **A**.
* If cell **C** holds **0**, the loop `[>]` is skipped entirely; `>>>>+<<<` advances to cell **G** to increment it, then goes back to cell **D**.
At this point, **D** will hold **d** (in fact, the sum of the values in **C** and **D** will always be **d**), so `[<+>-]` (while **D** is positive, increment **C** and decrement **D**) will set **C** to **d** and **D** to **0**.
Finally, `<<` retrocedes to cell **B**, `[<]` (go left while the cell is non-zero) further left to cell **A**.
In both cases, `>-` advances to cell **B** and decrements it, and the loop starts over unless this zeroes it out.
After **k** iterations, the tape looks as follows.
```
       v
A      B      C      D      E      F      G      H      J
0      n-k    d-k%d  k%d    0      0      k/d    0      k-k/d
```
After **n** iterations **B** is zeroed out and we break out of the loop. The desired values (**n%d** and **n/d**) will be stored in cells **D** and **G**, so `>>.>>>.` prints them.
[Answer]
## [Funciton](https://github.com/Timwi/Funciton), ~~224~~ 108 bytes
Byte count assumes UTF-16 encoding with BOM.
```
 ‚îå‚îÄ‚îÄ‚î¨‚îÄ‚îÄ‚îÄ‚îê
‚îå‚î¥‚ïñ‚ïì‚î¥‚ïñ ‚îå‚î¥‚ïñ
‚îÇ%‚ïü‚ïëf‚ïü‚îê‚îÇ√∑‚ïü‚îò
‚ïò‚ï§‚ïù‚ïô‚îÄ‚ïú‚îÇ‚ïò‚ï§‚ïù
 ‚îî‚îÄ‚îÄ‚îÄ‚îÄ‚î¥‚îÄ‚îò
```
[Try it online!](https://tio.run/nexus/funciton#fVMxbsMwDNz1Ci7diyD9UoAsHdI8wPCQKYPdionaRggQGOiSpUCAPKBT8wx@xJFoS6ZkIwZhSSR9vCOtFkhvSRds57BxVikOXAh3hB/dBqLLBcsnwiNhvfCLrpzj78pbowgNYUNoCT89GB5cNDqVg9GiUuEh/du0EB5CTVgJ2ysRq2H24hfp@@K0JuTbIeaiulQjRA8KUT0z8LoY3KMfA7kGFvIoO9RXlWY9GSPI2EghZdSvafnJlBJoW6d6RTgtlqeI6RbdBDMeutd4O0eRRmY8rCCJ5NAjcVOOB2MO2P@/6TBuVpzxBPN53pqJCQSHmFE2uildOWhH9offmLMP1JOOD60/cegwHJ872qP0S/rdLvu3v3PufJ9KWL6uafP@tl7x/ejpp7Ll/YiNEDpH11Kaae8 "Funciton ‚Äì TIO Nexus")
The above defines a function `f`, which takes two integers and returns both their division and their product (functions in Funciton can have multiple outputs as long as the sum of inputs and outputs doesn't exceed 4). 
Using two input values for multiple purposes is actually quite trivial: you simply split off the connector with a T-junction at the value will be duplicated along both branches, which we can then feed separately to the built-ins for division and modulo.
It actually took me twice as long to figure out how to display the result to the user than just to implement the solution.
Also, Funciton has a built-in divmod, `√∑%`, and amusingly the built-ins `√∑` and `%` that my solution uses are implemented *in terms of* `√∑%`. However, my function `f` above isn't *quite* identical to `√∑%`: I had to swap the order of the inputs and although it seems like it should be easy to change that, so far I haven't been able to do so without increasing the byte count.
[Answer]
# [APL (Dyalog)](https://www.dyalog.com/), 5 bytes
-2 bytes thanks to @ngn
```
‚åä√∑,|‚ç®
```
This is an atop (2-train) of a fork (3-train), where the atop's right tine is a derived function (the result of an operator applied to a function):
```
       result 
         ‚Üë‚îå‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îê
         ‚îÇ‚îÇ    ‚îå‚îÄ‚îÄ‚îÄ‚îÄ‚îê‚îÇ‚îå‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îê (derived function)
         ‚îÇ‚Üì    ‚îÇ    ‚Üì‚îÇ‚Üì      ‚îÇ‚ï±
       ‚îå‚îÄ‚îÄ‚îÄ‚îê ‚îå‚îÄ‚îÄ‚îÄ‚îê ‚îå‚îÄ‚îÄ‚îÄ‚îê ‚ïî‚ïê‚ïê‚ïê‚ï§‚ïê‚ïê‚ïê‚ïó
       ‚îÇ ‚åä ‚îÇ ‚îÇ √∑ ‚îÇ ‚îÇ , ‚îÇ ‚ïë | ‚îÇ ‚ç® ‚ïë 
       ‚îî‚îÄ‚îÄ‚îÄ‚îò ‚îî‚îÄ‚îÄ‚îÄ‚îò ‚îî‚îÄ‚îÄ‚îÄ‚îò ‚ïö‚ïê‚ïê‚ïê‚ïß‚ïê‚ïê‚ïê‚ïù
              ‚Üë ‚Üë         ‚Üë     ‚Üë ‚ï≤
left argument ‚î¥‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îò  (operator)
                ‚îî‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚îÄ‚î¥ right argument
```
`‚åä` floor of
`√∑` division
`,` catenated to
`|` division remainder  
`‚ç®` with swapped arguments (APL modulus is "backwards")
[Try it online!](https://tio.run/nexus/apl-dyalog#@5/2qG3Co56uw9t1ah71rvj/31QhTcGcC0QachlaACkTLiNTENfIFAA "APL (Dyalog Unicode) ‚Äì TIO Nexus")
[Answer]
# Regex (ECMAScript / Python), 57 bytes
```
(x(x*)),(x*?)(?=\1*$)(x?(x*))(?=\4*$)((?=\2+$)\2\5*$|$\4)
```
[Try it online!](https://tio.run/##TZBNU8IwEIbv/RXbGWSTBgoCegBjT44ndQYPHiyHDgRI7dckUavCb8eEFmUPSfbZzfsmmyYfiV4qWZm@ruRKqLws3sTXQfFCfMJcbO7qipBvfjsIDqQmdUBpz64RJRGPL4MOJXV0pC6fuNwdRqxD41F8FXR2nXhCD8Hgm4amfDZKFhtCQ53JpSDXvf6E0plXJVqLFXAYzjyhVKl0c16XCojkwxnIGz4aup0x2uDU4bTFqcXw44ENdxVrDJWoRGJISoEB9tCt/1RaU9ec22Yd5olZbolqmVw7cT6EyJan4Oew20H@Ol6EmSg2Zgs@B3mRNnRyTh8Ssw3XWVkqIgcpPb3IRWX/bW0ZwgCQpXbn8IrsTIBhDxwY/4MF9OFl/vR472P7NhfNgBhryB5EpsW503GWf2Vv71XvRhtF2gKCEdoga3OfX0aocYpIbalhzq1x8e0Yul1oFTAukLX2fzKnxnOZdSKzo8zhFw "JavaScript (SpiderMonkey) ‚Äì Try It Online") - ECMAScript  
[Try it online!](https://tio.run/##dVFNb8IwDL3zK1zUyUlboAV2AUUcd2PSLjtQDtUIkArSKglakfbfmdOifcF8sGw/2@/Fqc9uX@nJRR3ryjiwZ5sYOQcjTL/fv7CGNRHnCfkFZwuRZ1HIWbNoqz6f@twH4zjk@Th/jMKPMJ/yC02vstkgW89BibRXF9bKDQhIe9KYytg23FYGFCgNptA7ydJknKZxxmc9IPNg@R/o7Ug7jBxaWZi3PTMJYINRCTFggt5TpvhXt9rSALlSiBTkwUrQlaMSsRykZsfhzlSn2jK@mqx5INRoVN7Bxi32UH6r8FYbpR1TCY4wKRMUJGCFsXWG3Y7zGEnpPXDSgmvspLYScVlpSdsG8PryvHwKkP/ivZ4yFpB91f3cH3Xd7dsu@t@hdZvq5IbvRjnJvI6ugbjBSeswvhYCkUGhN4AW/SUQfUcHkQ4SeaUP6Cs7xpvtmOvuqV3rD4qucJdiW6iDp7h8Ag "Python 3 ‚Äì Try It Online") - Python
Takes its arguments in unary, as two strings of `x` characters whose lengths represent the numbers. The divisor comes first, followed by a `,` delimiter, followed by the dividend. The quotient and remainder are returned in the capture groups `\4` and `\3`, respectively.
I developed the basic form of this on 2014-04-03 while working on my [abundant numbers regex](https://codegolf.stackexchange.com/a/178952/17216). It had been a month earlier that teukon and I had independently come up with the multiplication algorithm [described here](https://codegolf.stackexchange.com/questions/179239/find-a-rocco-number/179420#179420), but up until this point we hadn't written or golfed any regex to find the unknown quotient of a known dividend and divisor. And it wasn't until [dividing by \$\sqrt 2\$](https://codegolf.stackexchange.com/questions/198427/shift-right-by-half-a-bit/198428#198428) that I adapted it to handle a dividend of zero correctly.
It is used, in its various forms (shown above or below), by these other regexes:
* [Abundant numbers](https://codegolf.stackexchange.com/questions/110708/an-abundance-of-integers/178952#178952)
* [Fibonacci numbers](https://codegolf.stackexchange.com/questions/126373/am-i-a-fibonacci-number/178956#178956) - the version that returns the index
* [OEIS A033286 (\$np\_n)\$](https://github.com/Davidebyzero/RegexGolf/blob/master/regex%20for%20matching%20OEIS%20A033286.txt)
* [Factorial numbers](https://codegolf.stackexchange.com/questions/121731/is-this-number-a-factorial/178979#178979)
* [Proth numbers](https://codegolf.stackexchange.com/questions/89436/is-it-a-proth-number/179076#179076)
* [Consecutive-prime/constant-exponent numbers](https://codegolf.stackexchange.com/questions/164911/is-this-a-consecutive-prime-constant-exponent-number/179412#179412)
* [Is the number binary-heavy?](https://codegolf.stackexchange.com/questions/132243/is-the-number-binary-heavy/179436#179436)
* [Euler's totient function](https://codegolf.stackexchange.com/questions/83533/calculate-eulers-totient-function/180255#180255) by Grimmy
* [Shift right by half a bit](https://codegolf.stackexchange.com/questions/198427/shift-right-by-half-a-bit/198428#198428)
* [Decompose a number!](https://codegolf.stackexchange.com/questions/78961/decompose-a-number/249369#249369)
Commented and indented:
```
(x(x*)),          # \1 = divisor; \2 = \1-1; tail = dividend
(x*?)(?=\1*$)     # \3 = remainder of division; tail -= \3
(x?(x*))          # \4 = conjectured quotient - find the largest one that matches the
                  #      following assertions; \5 = \4-1, or 0 if \4==0; tail -= \4
(?=\4*$)          # assert tail is divisible by quotient
(
    (?=\2+$)      # assert tail is positive and divisible by divisor-1
    \2\5*$        # assert tail-(divisor-1) is divisible by quotient-1
|
    $\4           # if dividend == 0, assert that quotient == dividend
)
```
To show what's going on, here is a Python function that does division using the regex's algorithm:
```
def modulo_is_zero(n, modulus):
    return n==0 if modulus==0 else n>=0 and n % modulus == 0
def divide(dividend, divisor):
    if divisor==0:
        return
    remainder = dividend % divisor
    dividend -= remainder
    quotient = dividend
    if dividend != 0:
        while 1:
            if modulo_is_zero(dividend - quotient, quotient) and \
               modulo_is_zero(dividend - quotient, divisor-1) and \
               modulo_is_zero(dividend - quotient - (divisor-1), quotient-1):
                break
            quotient -= 1
            if quotient == 0:
                return
    return [quotient, remainder]
```
[Try it online!](https://tio.run/##nVM9T8MwEN3zKy4DcqK6bQIbklnZQGJhAISC7FCH1m5thwr@fPFX46R0QHjJ3bvze3fny/bLrKS4Ohwoa2Ejab@Wr1y/fjMlC4ED0uvyOgN7FDO9EiAIqYC3x6Dz2FozEDfWagQFARfHIBACVZY5dso/OWVF@AiKPaCliuS8PQKWMEBJM8pvGi4oU0DgyGKV4i2fMsBzktJ9ZNdLw5kwo7tjWX8pt7Um5f2KrxnUCYjpJ1NKkoMGHqzSz@N5QmHPXyhiW/P63xzWLBJLKso616ds8KZY8zFBEw2B@nQIaZyTmZ19Nb80T6mz4WFeDnyzlcqA/tLZttGaUXDrwpSSSnuzlQo4cAGqEe@sqPBlVcXqXag7H/LlDy9dcNyV2bj4nNxJwZzZDdu7IwG0rLun6iUnfLnsglc776KbtrlVXBhLjZYIdxgRhHcYzeHx4f7uNkflJDc2NBsP0omeMIYJ@Cw7kYU2VPZmsVfcsEIbVYSEcobAMG3QLAI5qf2KII1cvQi5jBCyddgmo3xa71/s6FmgmZMIqSOJAJyVaBv7g1iJww8 "Python 3 ‚Äì Try It Online")
Notice that in regex, \$0 \equiv 0 \pmod 0\$. This is very convenient, as it allows a quotient of \$1\$ to be returned with no special case. The only special case we actually need to handle is when the dividend is zero.
First, to demonstrate that the correct answer satisfies the assertions used ‚Äì assume the remainder has already been subtracted away, and we are dividing \$B=C/A\$:
\$\begin{aligned}
C &= AB \\
C-B &= (A-1)B \\
C-B-(A-1) &= (A-1)(B-1)
\end{aligned}\$
Thus,
\$\begin{aligned}
C &\equiv 0 \pmod A \\
C &\equiv 0 \pmod B \\
C-B &\equiv 0 \pmod {A-1} \\
C-B-(A-1) &\equiv 0 \pmod {B-1}
\end{aligned}\$
The last two can be simplified to:
\$\begin{aligned}
C &\equiv B \pmod {A-1} \\
C &\equiv A \pmod {B-1}
\end{aligned}\$
At this point it becomes apparent why neither of these two alone would be enough. If \$A<B\$, it looks like the first one could yield false positives, and if \$B<A\$, it looks like the second one could. It turns out that only one of them is needed if we're guaranteed the input meets certain constraints, but until recently I simply accepted this intuitively and from testing the algorithm up to large numbers.
Unlike the [multiplication algorithm](https://codegolf.stackexchange.com/questions/179239/find-a-rocco-number/179420#179420), this division algorithm can't simply be proved correct from the Chinese remainder theorem, because \$C\$ is now constant while \$B\$, which defines one of the moduli, is the unknown. But [thanks to H.PWiz](https://chat.stackexchange.com/transcript/message/57537223#57537223), we finally have a rigorous proof for why the generalized form of division always works, and rigorously defined thresholds for when the division works in its two shortened forms.
Now let's look at ways to shorten the regex. First, if we assume \$C\ge A\$, it becomes **50 bytes**:
```
(x(x*)),(x*?)(?=\1*$)(x(x*))(?=\4*$)(?=\2+$)\2\5*$
```
[Try it online!](https://tio.run/##TZFNU8IwEIbv/RXbGXSTBgoiegAiJ8eTOoMHD@KhgwES@zVJVFT47Zg0VdlD0n128747W5W9Z2apZW17ppYvQhdV@So@D5qX4gPmYn29rQn54lf95EC2ZJtQ2nXnjJIZX5wlHdpCn4586u4h69DFcHGRdA5J/4umtnqwWpZrQlOTy6Ugl93eiNJJVGfGiBfgMJhEQutKm/C9qjQQyQcTkFM@HPibMRqw8li1WDkM3xG4kCv3BKagaJP6WFalleWbmDTEa@MWUy1qkVmiKDDALvrzn0oamgvXbNIis8sN0S3zDorzAcxceQxxAbsdFE/nz2kuyrXdQMxBnqhAR8f0NrObdJVXlSayr@jvyD5qtxhnyxD6gEy5203JSOFM8AnZkRDDLnhw/g@e0c2Bd1UpkLqXPXic39/dxNgO7COslbFA9iByI47tmz/wV472Uf1mjdWkLSBYYawbKOQxP5uhwTE2foF5t@ASu92cnkKrgIsSWWv/J/PbeCyzymTeyBx@AA "JavaScript (SpiderMonkey) ‚Äì Try It Online") - ECMAScript  
[Try it online!](https://tio.run/##dVHBbsIwDL3zFQYxOaGhtLBdYBHH3Zi0yw6UQwUBUkFSJUGDr@@SttoYMB/c@j3b77UuL26v1aSSx1IbB/ZimREzMNz0er2KnMl5QCnzeU7JnGfpoE9bMJTPofTPcdSn2Th7GfQrP7ZMp8N0NQPJk06ZWys2wCHpCGO0sfXrVhuQIBWYXO0ESdg4SaKUTjvgI5DFf2QIufXDr1D8IiHWWjmpTuIHPHopI2IrcrPeE8MAzzgoIAJkGLKvJL1eegyp4DwBcbAClHYe8mYOQpFjvDP6VFpCl5MV7XI5GhUPuHHNPd1YK41UjkiGI2QFQ45seb@TPdi1amzVdhZaCYZD@Px4X7x1kf5RaP9txCH9wcPUjY/mGHWXv3Rs3UafXPxlpBPEOkOaBhohOGEdRi3Q5SnkagNoMXwzYuhoKO/DW2zlu/62jeLddswURkGiab2SaICHEttcHoJE9Q0 "Python 3 ‚Äì Try It Online") - Python  
[Try it online!](https://tio.run/##nVPBjpswEL3nKwZVkUGQDbS3qu61t63USw@7qxUbho1pYie26Xb78@nYBgxpK1VFSNgzz@@9mTGnV7tX8t3l0mALR9X0B/UozONP1CqVRYj0Jnu/Ano02l5LkJyXINox6XZ4MAjyI61q2YCE9ZgEzqFcrRx7I76LBtPwkU3hA0bpgVyMCCL4MOZCyj1DAHhEwRvAY3@oLYLdI9RPBuUOQbVkgt7dnuBC@pzGZ/wxlyEq8h3pQ2lDlcdayAYXWuvx1Go048MbHuE@c@6VFSjt7KyPv@zFAaGKguQjYqlHMXNlZwBfzSY6mGiKaZX5KdzPGf/l@FDhpvqv87RMI0M0Q5tlbU8a629TJB7nUM1v2V00NrX44SKOJ6UtmFezOtXGYAPufqHWShu/bN3Q3dh1LZ8xLYu3ZZmPFlyy@1tyaLSg29ctHe@UtEL2GE1P401F0WWLoSb8Vkl0y276M848BEn@fFc@JFxst13YVW63vhI8aSEtUbMtK7qCcVacC7aBr18@335KWLbADrXnY/t8jESvGEOzPIqad2Nso3p786KFxdRYnQZAljOwaCzLh0DCK38ZmGHOL2MOEVLkg4oc5JPpCv/Gzu4ly51EgM4kQuCPEm1N/wtJXH4B "Python 3 ‚Äì Try It Online") - Python equivalent
If we know that all divisors will be in the required range, the division regex can be shortened further.
With \$C \equiv A \pmod {B-1}\$ and \$C \equiv 0 \pmod B\$, we need to find the *largest* matching quotient.  
With \$C \equiv B \pmod {A-1}\$, we need to find the *smallest* matching quotient.
---
Coming in at **42 bytes**, here is the case of using only \$C \equiv A \pmod {B-1}\$ and \$C \equiv 0 \pmod B\$:
```
(x(x*)),(x*?)(?=\1*$)(x(x*))(?=\4*$)\2\5*$
```
[Try it online!](https://tio.run/##XVJNU9swEL3nV6xnAElW4nyQ9oAROXV6ajsDBw6EYdygJBKxrEhKEyj57enKNiTTPWilt6v3nrzWxZ/Cz5yyoeetepaurMyLfD04YeQWbuXi285S@iZu@umB7uguZayL64TRiZgO0zPWgvE4xuN0NP2Snh3S/hvLQnUXnDILyjK/UjNJv3Z7Y8byznxjZkFVBpR/sk6V8slWW@moYfC3AxjzygG1YtSFtfhRhGU2X1WVo/XWr13ATpbnYDnHG2oO1JxbIQYMfjtZvOQQIXsj1gycDBtnILiNzPc193apVvJ4w/SFzT/ajBDDvLPv2MJ7@QwCBnlHOlc53@xrX0oMUOFajAYxo4UG1hHWLaxrZ7Ve9KITMYCLC1CJ0DGPU6qgB@pcM7gWoFMNHEZpXUMibH5/RwkdU/LfR9KMsZo4xqwyQRl8W41El2RHMietLAJ2IivpkrgeUcWa5hKbfVYWYbakrsVqr1F@guUrSMpooHy4fMxW0izCEhIRTTfo@BQ9mZLqo8X28THQvEFZTqAPhGvMAh4IPyHgpAsRuDwCj/h57m9//fyekNZbjGYWnDfIHuTKy1Olemyf5TjITfDB0bZAIEgfCG/PiRhOiCdXhDAsNVhUa1TakbUMZGoIb@U/aT4aT2nmBf5ekebwDw "JavaScript (SpiderMonkey) ‚Äì Try It Online") - ECMAScript
This can be shortened further, thanks to a trick [found by Grimmy](https://chat.stackexchange.com/transcript/message/49138588#49138588) (and used in [this post](https://codegolf.stackexchange.com/questions/83533/calculate-eulers-totient-function/180255#180255)). I've used it to shorten [factorial](https://codegolf.stackexchange.com/questions/121731/is-this-number-a-factorial/178979#178979), [Proth](https://codegolf.stackexchange.com/questions/89436/is-it-a-proth-number/179076#179076), [\$np\_n\$](https://github.com/Davidebyzero/RegexGolf/blob/master/regex%20for%20matching%20OEIS%20A033286.txt), and [consecutive-prime/constant-exponent](https://codegolf.stackexchange.com/questions/164911/is-this-a-consecutive-prime-constant-exponent-number/179412#179412) regexes. As a standalone division regex, it comes in at **39 bytes**:
```
(x+),(x*?)(?=\1*$)((x*)(?=\1\4*$)x)\3*$
```
[Try it online!](https://tio.run/##XVJNc9sgEL37V6xmkgDClj/i6SEK8anTU9uZ9NBDnMmoDrYhFsKAazWNf7u7SErs6R4E@3Z578FKF78Lv3DKhoG36lm6sjIv8s/RCSP3cC9Xn2tL6au4G6ZHWnPWp3U6Y3Qm5uP0glHM2mQ@xbRm8@v04pgOX1kWqh/BKbOiLPMbtZD0U38wZSzvLXdmEVRlQPkn61Qpn2y1l44aBn97gLGsHFArJn3Yiq9FWGfLTVU52mz91gXsZHkOlnM8oZZAzaUVYsTgl5PFSw4Rsndiy8DJsHMGgtvJ/NBw79dqI08nzFDY/L3NCDHOe4eeLbyXzyBglPekc5Xz7b7xpcQIFW7FZBRXtNDCOsK6g3XjrNGLXnQiRnB1BSoROq7TlCoYgLrUDG4F6FQDh0na1JAIm9/eUELHJfnvkTRjrCGOsahMUAbv1iDRJalJ5qSVRcBOZCV9Er8nVLG2ucRmn5VFWKyp67DGa5SfYfkGkjIaKB8mj9lGmlVYQyKi6Ra9PkfPpqSGaLG7fAw0b1CWExgC4RpXAQ@EnxFw0ocITE7AIz7Pz/vv374kpPMWo50F5y1yALnx8lypGdtHOQ5yF3xwtCsQCNIHwrs8EeMZ8eSGEIalFotqrUo3so6BzA3hnfwHzXvjOc2ywN8r0hz/AQ "JavaScript (SpiderMonkey) ‚Äì Try It Online") - ECMAScript  
[Try it online!](https://tio.run/##dVLBbuIwEL3zFZOqyHYSIKE9Qb097q0rrVbqAVCVLabYS@wwNoJ@PWs7WZS2rA@JZ96bec/2NO9ua/TdWdaNQQf23eYo5oAcb25uzvSUsZye0kdGH/myTG8Z9VEbLO99eGLLu/T27LmLcjYqV/NBr1Fdue1gLTYg7UuDshYvjTkKpJrNBuBXw6dz2PNAG292xiCNW7tH5zksco5buRNQtgVhyQ3oYcN5MYPfKKo/faD5xvczQOEOqOEXHsQFbDJe9vr966AnvInprkZzT2sqa8UaOBQDgWjQxu3GIEiQGrDSb4IW@bQosrI7SQDV/8DOnEp4AZVeg0y4ipv7lEoYgRwqBg8cVKogg2naglR5hxBEH1T4aeM@36NiPYWwXo12Uh/E/JKtvXcUYysqfN1SzIGcSJQhOQlfH0nWd1lHq0Fa7KyIqnWQ3wlN6/EbmkNjKVtMVyzhcjJRV7AyYkP10Zs3rh2VOZmQXOWEewMLklmH9Gs5y4h3eg2cRnBFWqvRInkyWvhuI3j@@ePpe0LYB93uCTMO5SUf6j65a988svzojq1bm4MbH1E6QYOPluC1wQnrSNYlEl7G1yKWhJsgJDBayPvwJjv5xI9Qq/ilO1nq9qgttSfRJq5KbCo/xl7i/Bc "Python 3 ‚Äì Try It Online") - Python  
[Try it online!](https://tio.run/##hVNNc5swEL37VywHj4TBH7g9JVGuvaUznc70kGQ8pIhaqi2BJOpJ/7yrL8CmyYQLq7er9x67S/Nq9lJ8Op8rWsNRVt1B7pje/aVKYpEHpNPpzQzso6jplABByAZY3SfdiR40BXFvo1JUIGDeJ4EQ2Mxmjr1if1hFcXiJKveAliqSs7oHLGGARs0ofyyZqKgCAj2LVYq3fMkAL8lY7jNtJw2jwlzc9fhpzw4UilHQ@hhrrfkxM7ETiydNGx0MNPkQpb49T5eMH1@3IY7fuCzSkcwerr29KFr@HpDxOoHicnyPo6@hRc9ndmykMqBfdX4szd5PzJpqFDvSXSNPVGER9RqyvYWWuLJVfZBSYR/qVhlbk77bVjFv3GgnPm2iuSftTW/vu@rokGwyUlzw9QxiTZrJRhazptSaVuD2jSollfZhLRUwYAJUKX5RvMm3m75vLsXfTkVjPIkbzRLCffB5gZkdCJvzFO4I8AWHDLaLkMTc/QtO8I67l5Bm2kOeTob2UwrDREdvx8ENK4pZztOrxUzIgxTUWxt@u5YE0Aq2j5vnhLD1modT4U5zfq1o7QhjqdEa5TxHBOVtjpbw49vXhy8JSq9qYyOzfoU8ZkUnjKHzvsou0EqbSnZmdVLMUKyNwqEgzRAYqg3KIpCQwvcNaeT8IuQqQsr6sB8Z5ZPhN/yPHT0JlDmJUHohEYA3JerSLpOVOP8D "Python 3 ‚Äì Try It Online") - Python non-regex equivalent
```
(x+),             # \1 = divisor
(x*?)(?=\1*$)     # \2 = remainder of division; tail -= \2
(                 # \3 = conjectured quotient - find the largest one that matches
    (x*)          # \4 = \3-1; tail -= \4
    (?=\1\4*$)    # assert tail-(quotient-1)-divisor is divisible by quotient-1
    x             # tail -= 1
)
\3*$              # assert both tail and dividend are divisible by quotient
```
The above algorithm is guaranteed to return the correct quotient if at least one of the following constraints is met (along with \$C \equiv 0 \pmod A\$):
* \$A^2+2A < 4C\$ ¬†or equivalently¬† \$A+2 < 4B\$
* \$A=C\$ ¬†or equivalently¬† \$B=1\$
	+ This works because the regex subtracts \$C-(B-1)-A\$ in order to assert that it is \$\equiv 0 \pmod {B-1}\$, and that subtraction will always result in a non-match (as it can't have a negative result) if \$A=C\$, unless \$B=1\$.
* \$A\$ is a prime power
	+ One of the cases in which this must be true, is when \$C\$ is semi-prime and neither of the two other conditions are met. It also must be true if \$C\$ is a prime power.
The proof of the first constraint follows. We start from the assertions made by the regex:
\$\begin{aligned}
\qquad C &\equiv 0 \pmod B \\
C &\equiv A \pmod {B-1}
\end{aligned}\$
Suppose the algorithm finds a \$B'\$ satisfying these moduli, with \$C=A'B'\$. Since the search for \$B\$ is done from largest to smallest, the only way for it to first find a \$B'\ne B\$ is with \$B<B'\$. Then:
\$\begin{aligned}
\qquad C &\equiv 0 \pmod {B'} \\
C &\equiv A \pmod {B'-1} \\
A'B' &\equiv A \pmod {B'-1} \\
B' &\equiv 1 \pmod {B'-1}
\end{aligned}\$
So, by modular division of \$A'B'/B'\$,
\$\qquad A' \equiv A \pmod {B'-1}\$
Due to \$AB=A'B'\$ and \$B<B'\$,
\$\begin{aligned}
\qquad A &> A' \\
A &\ge A'+B'-1
\end{aligned}\$
Due to the [AM-GM inequality](https://en.wikipedia.org/wiki/Inequality_of_arithmetic_and_geometric_means), we have:
\$\begin{aligned}
A'+B' &\ge 2\sqrt C \\
A'+B'-1 &\ge 2\sqrt C-1 \\
A &\ge 2\sqrt C-1 \\
{(A+1)}^2 &\ge {(2\sqrt C)}^2 \\
A^2+2A+1 &\ge 4C
\end{aligned}\$
So for a \$B'\$ to be found, \$A^2+2A+1 \ge 4C\$ must be true. Therefore, if \$A^2+2A+1 < 4C\$, no such \$B'\$ will be found. But \$A^2+2A+1 = 4AB\$ has no solutions:
\$\begin{aligned}
A^2+2A+1 &\stackrel?= 4AB \\
A &> 0 \\
A+2+{1\over A} &\ne 4B
\end{aligned}\$
So we can simplify the inequality that guarantees no \$B'\$ will be found:
\$\begin{aligned}
A^2+2A+1 &\le 4C \\
A^2+2A &< 4C
\end{aligned}\$
And now the proof of the prime power constraint. Suppose that \$A\$ is a prime power and the algorithm has found a \$B'\$:
\$\begin{aligned}
\qquad A&=p^n \\
A'B'&=C\\
B'&>B \\
A'&<A \\
A' &= p^{n-k},\ k>0
\end{aligned}\$
So \$B'\$ must have gained the prime power factor that \$A'\$ lost:
\$\begin{aligned}
\qquad B' &= xp^k\\
B' &\equiv 0 \pmod p \\
A &\equiv 0 \pmod p
\end{aligned}\$
So \$A\$ and \$B'-1\$ are coprime, and we can do modular division by \$A\$, since it is not \$\equiv 0 \pmod {B'-1}\$:
\$\begin{aligned}
\qquad C &\equiv A \pmod {B'-1} \\
AB &= A\pmod {B'-1} \\
A &\equiv A \pmod {B'-1} \\
B &\equiv 1 \pmod {B'-1} \\
B &< B' \\
B &\le B'-1 \\
B &= 1
\end{aligned}\$
So for a \$B'\$ to be found when \$A=p^n\$, it must be the case that \$B=1\$, meaning \$A=C\$. But we already know that the algorithm works properly when \$A=C\$.
---
[Answer]
# JavaScript (ES6), 17 bytes
Thanks to @Arnauld for golfing off one byte
```
x=>y=>[x/y|0,x%y]
```
Receives input in format (x)(y)
Gets floor of x/y by performing bitwise or  
Gets remainder by x%y  
Puts both values in an array so that they can both be returned
[Try it online!](https://tio.run/nexus/javascript-node#S7P9X2FrV2lrF12hX1ljoFOhWhn7Pzk/rzg/J1UvJz9dI03D0EBTw0RT8z8A)
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 6 bytes
```
{√∑|%}·∂†
```
[Try it online!](https://tio.run/nexus/brachylog2#@199eHuNau3DbQv@/482MjXVMTKN/R8FAA "Brachylog ‚Äì TIO Nexus")
### Explanation
We abuse the metapredicate `·∂† findall` to apply two different predicates to the Input list of two arguments:
```
{   }·∂†         Findall for the Input [A,B] :
 √∑               Integer division
  |              Or‚Ä¶
   %             Modulo
```
[Answer]
# Java 8, 18 Bytes
`(a,b)->a/b+","+a%b`
This is a lambda expression of the type `BiFunction<Integer, Integer, String>`.
I'm surprised... this is actually a fairly concise solution for Java. Go lambda expressions!
[Answer]
# [MATL](https://github.com/lmendo/MATL), ~~12~~ 10 bytes
```
Qt:ie=&fhq
```
Input is `a`, then `b`. Output is remainder, then quotient.
[Try it online!](https://tio.run/nexus/matl#@x9YYpWZaquWllH4/7@RqSmXkSkA "MATL ‚Äì TIO Nexus")
### Explanation
This avoids both modulo and division. Instead it uses *array reshaping*:
1. Build an array of `a+1` nonzero elements.
2. Reshape as a 2D array of `b` rows. This automatically pads with zeros if needed.
3. The row and column indices of the last nonzero entry, minus `1`, are respectively the remainder and quotient.
Consider for example `a=7`, `b=3`.
```
Q    % Input a implicitly. Push a+1
     % STACK: 8
t:   % Duplicate. Range from 1 to that
     % STACK: 8, [1 2 3 4 5 6 7 8]
ie   % Input b. Reshape as a matrix with b rows (in column major order)
     % STACK: 8, [1 4 7;
                  2 5 8]
                  3 6 0]
=    % Compare for equality
     % STACK: [0 0 0;
               0 0 1;
               0 0 0]
&f   % Row and column indices (1-based) of nonzero element
     % STACK: 2, 3
hq   % Concatenate. Subtract 1. Implicitly display
     % STACK: [1 2]
```
[Answer]
# Regex (Perl / PCRE), ~~36~~ 35 bytes
```
x(x*),((x(?=((?(4)\4)\1)))*)\4?(x*)
```
[Try it online!](https://tio.run/##VVFRb4IwEH7nVxyks6040ExfxA5NXPbmkmXJHtQQs9UNg2AKDyyO/XV2BWq0IU3v@@6@@7g7SZVM6uMPEBXAOck@dgkQP8BQzJaLt8VjZVnktMtz@QkChoFFpFKZyttgnylgJBZDLIhn4mHSPFyXw7njDg13MNyh5QAP0RqMlhRKxDl4QAcUbwPFPGjy5kfM08l/4BPlt2C8b7TFEEKdMAUb799fSGT6VXyz@XE93nKwsTCGO5S/5UYtF6cFmgdftzeu9DkpZMDpKOzueFiFnRhdU@9GxqMDuIbGGtpSjo7oKksl5Z4D9/D@@rJ6tjepE1yadHN03RaqQCa5vDLRDf3CW1VlGWPdPgqZF2itC20xCmlOp7Tp2WLOZV82jqrXM7@2Sc0ajYbJutbY7@Kk0Yiip9UyiuqSlX0@YKxkoWAsZGO@wW/EOe/jK9RsXf8D "Perl 5 ‚Äì Try It Online")
Takes its arguments in unary, as two strings of `x` characters whose lengths represent the numbers. The divisor comes first, followed by a `,` delimiter, followed by the dividend. The quotient and remainder are returned in the capture groups `\2` and `\5`, respectively.
In contrast to the [ECMAScript regex solution](https://codegolf.stackexchange.com/questions/114003/division-and-remainder/222932#222932), this one doesn't have to do anything anywhere near as fancy or mathematically interesting. Just count the number of times \$divisor\$ fits into \$dividend\$ by splitting the divisor to keep two tandem running totals that are both subtracted from \$dividend\$, one that keeps subtracting \$divisor-1\$, and one that keeps subtracting \$1\$ and adding it to the total quotient. We must do a split like this, because regex refuses to repeat a zero-width group more than once (this, along with the limited space to work in, is exactly what prevents it from being Turing-complete).
I never wrote a division algorithm in any regex flavor besides ECMAScript before. So it's interesting to now know how they compare in golfed size.
```
x(x*),                    # \1 = divisor-1; tail = dividend
(                         # \2 = what will be the quotient
    (
        x                 # tail -= 1
        (?=
            (             # \4 = running total
                (?(4)\4)  # recall the previous contents of \4, if any
                \1        # \4 += divisor-1
            )
        )
    )*                    # Loop the above as many times as possible (zero or more); if
                          # it loops zero times, \4 will be unset (we'll treat that as 0)
)
\4?                       # tail -= \4, or leave tail unchanged if \4 is unset
(x*)                      # \5 = remainder
```
# Regex (Java), ~~41~~ ~~40~~ 38 bytes
```
x(x*),((x(?=(\4\1|(?!\3)\1)))*)\4?(x*)
```
[Try it online!](https://tio.run/##fVNNc9owEL3zKxbPMEjgmNAkl7oapum0vTRJJzn0gDkILIOMLbuSCM4k/Ha6wiaBhKlmQKt9b7/XKX/kZ2m83Mq8LLSFFN@BLIJeCIealZXZSZ0Wc1Eh0hr0er1tRaoe9QmpyIiR6DIavpBRO7qg0ZBS2qPR5cgRtkgdtMrVNJMzmGXcGLjhUsEzNDpjucXrsZAx5IiQB6ulmgPXczOeULALXawNfK9morSyQMsW4PkhMwEJU2K9E4kXzIpYBMjwaHi9ShKhRXwveCw0THe0YyXZWzbPhNKwiWx8G64Xzj8hhk2xbB7/kkoQSttMrbKMyoSYQPxd8cwQzzXDo/T5mFp7IMSedPCMHuyrB9ci9DBF3jI0fdaNVNfdNtzUus1vbq3QCjRrJKw2L10AQ8NdP6SyUGJ3RczOfRBaF9qw8xpLpOLZjpHzSrKLK2SglDqpZswWXI8nFTBwbdm9HAH6MMSfs5qE8FVr/mSCRGYZqfxu1W1CJ4UG4rxLDAjyC3N8FPp9eoynDk93eIoC4s0w3anG6QTjd/1u@Kq74Xa2wAHmCOggr19kt5AK9/Yb5llPNVhrXpImwVlRPt0l91zNBeYJWOy@EImb@eb9uigywRUs0XuOZamYHKAyAZIydg4jJHyG9hJeXpA218WqJJ9okAk1twuCE5WD9BC7OsI66WGR7jw8GSvyoFjZoMR9swnxOjEMAP8YeD5IzPcgj30uS3rKctyJfbScoN2J3PxTSdEQRGbEKW@3hRLeu9gnaHAGf@7vbn@2I/WeXS9ev/@m3dTRjntQb@oR7cMiVM0i1MjprllhbMc07rAHtbC/22yI0/OMh/Pz9pm6XtZZQpvBOW39p9BIvcVIOH5uLkZtvL8/xNhstv8A "Java (JDK) ‚Äì Try It Online")
This is a port of the Perl/PCRE regex to a flavor that has no conditionals. Emulating a conditional costs ~~5~~ 3 bytes here. The quotient and remainder are returned in the capture groups `\2` and `\5`, respectively.
```
x(x*),                  # \1 = divisor-1; tail = dividend
(                       # \2 = what will be the quotient
    (                   # \3 = the following (after the first iteration has finished),
                        #      which is always 1
        x               # tail -= 1
        (?=
            (           # \4 = running total
                \4      # recall the previous contents of \4 (only if it is set)
                \1      # \4 += divisor-1
            |
                (?!\3)  # Match this alternative only if this is the first iteration of
                        # the loop, meaning \4 is unset; \3 can never not match here if
                        # \3 is set (because \3==1) unless \1==0, in which case it
                        # doesn't matter if this alternative is taken instead of the
                        # above ‚Äì in that case, the value of \4 isn't changed anyway.
                \1      # \4 = divisor-1
            )
        )
    )*                  # Loop the above as many times as possible (zero or more); if
                        # it loops zero times, \4 will be unset (we'll treat that as 0)
)
\4?                     # tail -= \4, or leave tail unchanged if \4 is unset
(x*)                    # \5 = remainder
```
# Regex (Python[`regex`](https://github.com/mrabarnett/mrab-regex) / Ruby), 43 bytes
```
x(x*),((x(?=((?(5)\5)\1))(?=(\4)))*)\4?(x*)
```
[Try it online!](https://tio.run/##dVFNb8IwDL3zK1ykyQktpRVwAUUcd2PSLjtQDtUIkArSKgla@fWd06B9wawoSvye/V6c5uqOtZ526tzUxoG92sTIg2yXYIQZDoddy9oRTxhr2UowtmJzXtDKOff3YsY5H/FitvKsjvibfDHOt0tQIhs0pbVyBwKygTSmNrY/7msDCpQGU@qDZFkyzbI454sBUHiw@g/0caYevcHUytK8H5lJAFscVRADJuh3uin@VaD2VENbJUQG8mQl6NpRioROUrNzejD1pbGMb/Itj4SaTKoH2LzHnqpvIz4ao7RjKsEJJlWCggxsMLbOsPvWPEZy@gic9@AWg9XeIq5rLanbGN5eX9bPEfJfurdpxgLyr7yv@@MujL9n0b@m1u3qi0s/jHKSeR@BQNrgpHUY3xKRyKHUO0CLfhKInhEg8kEmb/IR/WZQvOuOhQ5PDdQfEiHxUGJfqpOX6D4B "Python 3 ‚Äì Try It Online") - Python `import regex`  
[Try it online!](https://tio.run/##ZVDRSsMwFH3vV9wWJck6u06nD45QBhPfJgzBByulsmymbGlJOqww/PV6m3SbaGhKzrkn555cvX//ajVwWIqNaKpIiU@Yz55nkRb5agqSx16VGyNWKIk9oXWpjT2uSw0SpII4im5ih4tfGHDtUEmDJhgUEEIwDLo/IsmAf4O2ErmGgvMYEhTfg7@DwwEurqOtUJv6w@dyVFjm7sxcFvZit6p9bUBGdZmZkMAISFgcAUdAd2hLXkl4MuyrQyyeLHvujWB/siiVIAzvX8HL8mnx6JNTs/7tIYex5cTWiHMSN6NzUa083FN7qLRUdS855quFqTGhI30@7pIaG8G2dzzxcDx9Xx@HPgVnFaQqCB3/x8@R//3Wudyin8uTZQ@LeZa1DW0GbEhpQxNOaUJvWYrfmLEOpxPG2IClk6RTte0P "Ruby ‚Äì Try It Online") - Ruby
This is a port of the Perl/PCRE regex to flavors that have no support for nested backreferences. Python's built-in `re` module does not even support forward backreferences, so for Python this requires [`regex`](https://github.com/mrabarnett/mrab-regex).
Emulating a nested backreference by copying the group back and forth costs 8 bytes here. The quotient and remainder are returned in the capture groups `\2` and `\6`, respectively.
```
x(x*),                    # \1 = divisor-1; tail = dividend
(                         # \2 = what will be the quotient
    (
        x                 # tail -= 1
        (?=
            (             # \4 = running total
                (?(5)\5)  # recall the previous contents of \4 (as copied into \5) if any
                \1        # \4 += divisor-1
            )
        )
        (?=(\4))          # \5 = \4, to make up for Python's lack of nested backreferences
    )*                    # Loop the above as many times as possible (zero or more); if
                          # it loops zero times, \4 will be unset (we'll treat that as 0)
)
\4?                       # tail -= \4, or leave tail unchanged if \4 is unset
(x*)                      # \6 = remainder
```
# Regex (.NET), 29 bytes
```
(x+),(?=(\1)*(x*))((?<-2>x)*)
```
[Try it online!](https://tio.run/##bVI9b8IwEN3zK66WK9skodB2gqYgdehGpS4dKAMqB0mUxKmdKpFQfju180FArQfLuvfu3bs757JEpUNMkhNVwVrhAavNbJZhyZfsxCtXeHwR8M@pGPFqJATniyf//rkSI3FiS4@8yDSPEtwRMXdovtUadxDAxKGolFS6ee@lAk6jYDIHGvkJwnTSPF1XwLFD4waNBzRuUTCHWhnOKjaisQAXmMfM3QYi0VJSQ6FqnG6LrxA1p7qNR3ujzZs7Bh@/YWJEaVoDJhrheGPyfFOfpuODkj@5Xj9sxglmhyIEP0PjEW7BZl5xHq84a1MzNCPbJ1Iq0ybcmQxRi969PaWKCvRDqQsgHcP6bY2lhknWlP9TQHhwGT@bExvSt0BWMkNSC/Dh4/1t9XpDzlW7HbhuE@kTBrhdVw87de1c@PQzo1smkemQ9IstUBfWNO8Ctv2pODLNaqt9ZMz4aCHiNL21DizPDn6Qn1@PpPssg/6Q90d/v23@W336BQ "PowerShell ‚Äì Try It Online")
This uses .NET's Balanced Groups feature. It returns the quotient and remainder in the lengths of `\4` and `\3`, respectively.
```
(x+),                     # \1 = divisor; assert \1 > 0; tail = dividend
(?=
    (\1)*                 # push \2 onto the stack for each time \1 fits into dividend
    (x*)                  # \3 = remainder
)
((?<-2>x)*)               # \4 = quotient: pop all \2 from stack, doing \4 += 1 for each
```
# Regex `üêò` (.NET), 14 bytes
```
(x+),(\1)*(x*)
```
[Try it online!](https://tio.run/##tVOxboMwFNz5ilfkynYIlLRbokiROnRrpS4dUoYoeQQQYGKDEini21PbkJC0HbrUg2W9O9/de5hK7FGqBPP8ROR8KXGLh2g6LXHPFvTEDh4fs88JH7HDiJ/oYuw@i6JKc9y4fOaQaqUUbmAOoUNQSiGVPcdCAiPpPJwBSf0cYRLao@dxOPZoZtFsQLMOBb2IkWH0QEck4@ABHVO9d4WUW0oaa41C04gMilW9TlAxovhZwarsGmEIRbCVoqnU8jEK1quqbiSqYC2ash6oEosb6lMU5Fhu6@RCsYYZ@LiDEHzdgr3jl6j7gnswkCkaT1Nc6lCJHmScCyH1LOBBU27imbWXaY1@IlQNbs/RMZZGZWwNIvDh4/3t9eXOvbnYT9vzLtUWMFf4Tb//QNc051fyuTudPPxbyFehuf8Tzmlb58rUL7XVPk@1n3t@cTWqmrA0Zn3BBJ/wI1W0NU5HSlsOHeQ6trku07nBQX5221//igf94d4P/Xhlf4T29AU "PowerShell ‚Äì Try It Online")
This uses .NET's Balanced Groups feature. It returns the quotient in the capture count of `\2`, and remainder in the length of `\3`.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 3 bytes
```
:,%
```
[Try it online!](https://tio.run/nexus/jelly#@2@lo/r//38jU1MgBgA "Jelly ‚Äì TIO Nexus")
[Answer]
## Mathematica, ~~20~~ 18 bytes
```
‚åä#/#2‚åã@Mod@##&
```
Minor abuse of the flexible output rules: the result is given as `div[mod]`, which will remain unevaluated. The individual numbers can be extracted with `result[[0]]` and `result[[1]]`.
And hey, it's only one byte longer than the ridiculously named built-in `QuotientRemainder`.
Mathematica, actually has a neat way to apply multiple functions to the same input, but it's three bytes longer:
```
Through@*{Quotient,Mod}
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 5 bytes
```
√∑¬≤¬π%‚Äö
```
[Try it online!](https://tio.run/nexus/05ab1e#@394@6FNh3aqPmqY9f@/kSmXkakpAA "05AB1E ‚Äì TIO Nexus")
~~05AB1E has a bug, so implicit input doesn't work :(~~ [Emigna](/users/47066) noted that inputs are often pushed in reverse.
[Answer]
## [Jellyfish](https://github.com/iatorm/jellyfish), 14 bytes
```
p
m
,|S
% i
Ei
```
[Try it online!](https://tio.run/nexus/jellyfish#@1/AlculUxPMpaqQyeWa@f@/kakpl5EpAA "Jellyfish ‚Äì TIO Nexus")
### Explanation
Jellyfish is a beautiful language when it comes to applying multiple functions to the same input. The language is 2D and all binary functions look south for one input and east for another. So by approaching one value from the west and from the north, we can feed it to two functions without having to duplicate it in the code.
The two `i`s in the program are replaced with the two input values when the program starts. Now `%` is division. It takes one input directly from the east, and when going south it hits the `E` which redirects that search east as well. So both inputs get fed to `%` as arguments.
`|` is the built-in for modulo, which basically does the same thing, but ends up looking south for both in puts.
We concatenate both results into a pair with `,`. Then `m` is the floor function (which we need because `%` is floating-point division) and finally we print the result with `p`.
[Answer]
# sed, 36 bytes
35 bytes of code, +1 for the `-r` flag.
```
:a;s/^(1+)( 1*)\1/\1\2x/;ta;s/.* //
```
Takes input in unary, space-separated, with the smaller number first. Outputs as unary, with the quotient first in `1`s and the remainder second in `x`s. (If this isn't acceptable, let me know and I'll change it to space-separated `1`s like the input.)
### Explanation
```
:a;                                  Define label a
   s/            /     /;            Perform this substitution:
     ^(1+)                           Match the first unary number...
          ( 1*)                      ... followed by a space and 0 or more 1s...
               \1                    ... followed by the the first group again
                  \1\2x              Keep the first two parts unchanged; replace the third
                                     with an x
                         ta;         If the substitution succeeded, goto a
                            s/.* //  After the loop is over, remove the first number
```
[Answer]
# [Cubix](https://github.com/ETHproductions/cubix), 12 ~~13~~ bytes
```
;W@o,I|\S%;O
```
Which maps onto the following cube
```
    ; W
    @ o
, I | \ S % ; O
. . . . . . . .
    . .
    . .
```
[Try it here](https://ethproductions.github.io/cubix/?code=O1dAbyxJfFxTJTtP&input=NywzCg==&speed=20)
Explanation with steps as executed  
`,I|I,` - starts with an superflous integer divide, gets the first integer from input, reflects back and gets the next integer from input, then divides again  
`O;` - Output the result of the integer division and pop it  
`%` - do the mod. This could be done later, but ended up here  
`S\o` - Add space character to stack, redirect up and output space  
`W;` - Shift left and pop the space from the stack  
`O|@` - Output the mod previously calculated, pass through the horizontal reflector and halt.
[Answer]
# [Brain-Flak](https://github.com/DJMcMayhem/Brain-Flak), ~~56~~ 54 bytes
```
({}<>)<>([()]{()<(({})){({}[()])<>}{}>}<><([{}()]{})>)
```
[Try it online!](https://tio.run/nexus/brain-flak#FYrBDQBACMLWgR0Mi5ibhDC7p58@2g6cEkto8BksrCG9PLMljvYptHNPKM58 "Brain-Flak ‚Äì TIO Nexus")
*-2 bytes thanks to [Wheat Wizard](https://codegolf.stackexchange.com/users/56656/)*
## Explanation
The current best known [integer division](https://github.com/DJMcMayhem/Brain-Flak/wiki/Basic-Arithmetic-Operations#integer-division-positive-only) and [modulo](https://github.com/DJMcMayhem/Brain-Flak/wiki/Basic-Arithmetic-Operations#modulo-positive-only) in Brain-Flak are very similar (in fact the currently used integer division is just a modification I made on [feersum](https://codegolf.stackexchange.com/users/30688/)'s modulo).
**Comparison of modulo and integer division:**
```
Modulo:   ({}(<>))<>     {   (({})){({}[()])<>}{} }{}<> ([{}()]{})
Division: ({}(<>))<>([()]{()<(({})){({}[()])<>}{}>}{}<><  {}   {} >)
```
Conveniently, the integer division program uses only the [third stack](https://codegolf.stackexchange.com/a/109859/20059) for storing data while the modulo program uses only the normal two stacks for storing data. Thus by simply running them both at the same time they do not collide at each other.
**Combination of modulo and integer division:**
```
Modulo:   ({}(<>))<>     {   (({})){({}[()])<>}{} }{}<> ([{}()]{})
Division: ({}(<>))<>([()]{()<(({})){({}[()])<>}{}>}{}<><  {}   {} >)
Combined: ({}(<>))<>([()]{()<(({})){({}[()])<>}{}>}{}<><([{}()]{})>)
```
Finally, both the integer division and modulo programs used in this combination were designed to be stack clean (not leave garbage on the stacks/not depend on the (non)existence of values on the stacks other than their input) but that is not necessary for this problem. Thus we can save two bytes by not bothering to pop the zero at the end of the main loop and another two bytes by not pushing zero at the start, instead relying on the zero padding on the bottom of the stacks.
**This gives us the final program:**
```
({}<>)<>([()]{()<(({})){({}[()])<>}{}>}<><([{}()]{})>)
```
For the explanation for the integer division program see [feersum's answer](https://codegolf.stackexchange.com/a/98312/20059)
### Integer Division Explanation Coming Soon...
[Answer]
# [Python 2](https://docs.python.org/2/), 20 bytes
```
lambda a,b:(a/b,a%b)
```
[Try it online!](https://tio.run/nexus/python2#S7ON@Z@TmJuUkqiQqJNkpZGon6STqJqk@b@gKDOvRCFNw1THXPM/AA "Python 2 ‚Äì TIO Nexus")
### Built-in, 6 bytes
```
divmod
```
[Try it online!](https://tio.run/nexus/python2#S7ON@Z@SWZabn/K/oCgzr0QhTcNUx1zzPwA "Python 2 ‚Äì TIO Nexus")
[Answer]
# [Brain-Flak](https://github.com/DJMcMayhem/Brain-Flak), ~~168 148~~ 110 bytes
I guess I should have checked the [Wiki](https://github.com/DJMcMayhem/Brain-Flak/wiki/Basic-Arithmetic-Operations) first
```
(({})(<({}(<(({})<>)>))<>([()]{()<(({})){({}[()])<>}{}>}{}<><{}{}>)>))<>{(({})){({}[()])<>}{}}{}<>([{}()]{}<>)
```
## Format:
```
Input:    Output:
A (18)    remainder (2)
B (4)     division  (4)
```
[Try it online!](https://tio.run/nexus/brain-flak#bYyxCcBADAP7TCKVgRQpjBd5Monw7I6cb1P4OGShBlREmMZ4JJMmFvgI3CllTuJPqeYiQ6O7rr/a18Lytqes7D7v43oB "Brain-Flak ‚Äì TIO Nexus")
```
(({})(<           # Copy A
({}(<             # Pick up A
(({})<>)          # Copy B to the other stack
>))               # Put A on top of a 0 on the second stack
                  # At this point the stacks look like this:   A
                                                               0
                                                             B B
                                                               ^
<>([()]{()<(({})){({}[()])<>}{}>}{}<><{}{}>) # Positive division from the wiki
>))                                          # Put down A on top of a 0
                                             # The stack now: A
                                                              0
                                                            Div B
                                                              ^
<>{(({})){({}[()])<>}{}}{}<>([{}()]{}<>)     # Modulo from the wiki
```
[Answer]
# [OIL](https://github.com/L3viathan/OIL), ~~134~~ ~~106~~ ~~103~~ 102 bytes
Takes the input from stdin, the two numbers seperated by a newline. Outputs the result of the integer division, then a newline, and then the remainder.
This is one of the most complicated OIL programs I've ever written, as OIL lacks builtins for division, remainder, addition, substraction, and so on. It works with the primitive way of doing division: repeated nested decrementation.
I present the code in an annotated format, with comments in the style of scripting languages. Before executing, the comments have to be removed.
```
5  # read input into lines 0 and 2
5
2
0  # the zero to compare to (nops)
1  # make a backup of the second input at line 3
2
3
10 # check if the second input is 0. %
4
2
24 # if so, jump to 24 (marked with ¬ß)
13 # else, go on
10 # check if the first input is zero &
4
31 # if so, jump to 31 (marked with $)
18 # else, go on
9  # decrement both numbers
9
2
6  # jump to line 8 (marked with %)
8
8  # increment the value in line 1 (initially a zero) ¬ß
1
1  # "restore the backup"
3
2
6  # jump to line 13 (marked with &)
13
10 # is the second number zero? $
4
2
42 # if so, jump to 42 (marked with +)
36 # else go on
9  # decrement both the second number and the backup
2
9
3
6  # jump to 31 (marked with $)
31
4  # print the division +
1
11 # a newline
4
3  # and the remainder (from the backup)
```
edit: Shaved off 3 more bytes by moving a "constant" to a one-digit location (less bytes to reference), and then implicit-ing 2 zero-locations (By using an empty line instead. One of them I could have done before).
edit: And another byte by making the initial zero implicit. We really only need a single literal zero.
[Answer]
# [Retina](https://github.com/m-ender/retina), 14 bytes
Let's abuse the input/output formats!
```
(.*)¬∂(\1)*
$#2
```
Takes input as `b\na`, in unary, using for unary digit any single non-digit, non-newline character. Outputs the quotient in decimal, immediately followed by the remainder in unary, using the same character as the input.
[Try it online!](https://tio.run/nexus/retina#@6@hp6V5aJtGjKGmFpeKstH//xVAwFWBAQA "Retina ‚Äì TIO Nexus")
`(.*) ¬∂(\1)*` matches the first number , then a newline (¬∂ is Retina's shorthand for \n), then the first number again as many times as possible. The number of matches of the second group will be the result of the division, and the part not matched will be the remainder.
With `$#2`, we replace everything that was matched in the previous line with the number of captures of the second group, and get then our result.
[Answer]
# Excel 2013, ~~31 30~~ 26 bytes
```
=INT(A1/B1)&","&MOD(A1;B1)
```
# Explanation
Input is in cell `A1` and `B1`. This simply returns the return values of the `FLOOR` and `MOD` function, which are for flooring the division and for the remainder. These values are separated by a comma.
[Answer]
## [Labyrinth](https://github.com/m-ender/labyrinth), 11 bytes
```
?:?:}/!\{%!
```
[Try it online!](https://tio.run/nexus/labyrinth#@29vZW9Vq68YU62q@P@/kampgpEpAA "Labyrinth ‚Äì TIO Nexus")
### Explanation
```
?:   Read a and duplicate.
?:   Read b and duplicate.
}    Move a copy of b over to the auxiliary stage.
/    Compute a/b.
!    Print it.
\    Print a linefeed.
{    Get back the other copy of b.
%    Compute a%b.
!    Print it.
```
The IP then hits a dead end, turns around and the program terminates due to the attempted division by zero when `%` is executed again.
[Answer]
# C, 32 bytes
```
f(a,b){printf("%d %d",a/b,a%b);}
```
[Try it online!](https://tio.run/nexus/c-clang#DchLCoAgEADQqwyFoGCfTW2M7jL@UKgxzFbRsVtbb/naSGa7rFvOYmPqw1o9R6nFfeRIxfOGWWC2kThoiUwL9dT/YcdIXNzg@SRnoSC7cmWCUcFTX0qdQRPcBw "C (clang) ‚Äì TIO Nexus")
[Answer]
# [ArnoldC](https://lhartikk.github.io/ArnoldC/), ~~286~~ 283 bytes
```
HEY CHRISTMAS TREE c
YOU SET US UP 0
HEY CHRISTMAS TREE d
YOU SET US UP 0 
GET TO THE CHOPPER c
HERE IS MY INVITATION a
HE HAD TO SPLIT b
ENOUGH TALK
GET TO THE CHOPPER d
HERE IS MY INVITATION a
I LET HIM GO b
ENOUGH TALK
TALK TO THE HAND c
TALK TO THE HAND d
YOU HAVE BEEN TERMINATED
```
[Try it online!](https://tio.run/nexus/arnoldc#dc87DsIwEEXRPqt4HS1IFLSGjDIj4o8846CUQPa/heAI0SShsWTr6OpZ7KBQjg8TTw3TiBtnUfNOYZkIz2aMBUqGoigJp8ueeq3Ued5B7xU67pWmDWq6erEIY6o4pkS5ppgyQRR@hIRBzJnEUNdWxK5dvKZerC6jEEvHMNffd1vT35agr5zFo4vr0HL@SuxCWydtnr5/YTcQrkQBRtlLcEbtPH8A "ArnoldC ‚Äì TIO Nexus")
### How It Works
```
HEY CHRISTMAS TREE c      //DECLARE VARIABLE c = 0
YOU SET US UP 0
HEY CHRISTMAS TREE d      //DECLARE VARIABLE d = 0
YOU SET US UP 0
GET TO THE CHOPPER c      /*
HERE IS MY INVITATION a      SET c = a/b
HE HAD TO SPLIT b         
ENOUGH TALK                */
GET TO THE CHOPPER d      /*
HERE IS MY INVITATION a      SET d = a mod b
I LET HIM GO b
ENOUGH TALK                */
TALK TO THE HAND c        // PRINT c
TALK TO THE HAND d        // PRINT d
YOU HAVE BEEN TERMINATED  //END
```
### Output Format
```
a/b
a mod b
```
[Answer]
# [Quipu](https://esolangs.org/wiki/Quipu), 54 bytes
```
\/\/[]\n[]
    1&/\1&
    []  []
    //  %%
    /\  /\
```
[Try it online!](https://tio.run/##zVltU9tGEP6uX7FRBpBCsHHbTy6mDaSdps3bNJnpB0w7h3y2lciSqjsDHo9/O93duxOSX8CCMNNkAOtu79ndZ1d7d2sViUTctNsfhdISZtm0gCgbSIhT0GNpPisZ6ThLQaQDHozTfKqdhHmwIi14nSWJKEDFo1TBWFxK0BlcSJAqErkcwFWsxzCoCHnxJM8KhMtan1B7JN1AhEIWdTLV4iKRrVdFIWYn0@FQFl528QVn4Z1AO@S1lulAwas8n@tiNn@TalnkhcTfwUdRKPxTwreGRTY5mWmpgpNEjlt5kY1aI6l5KAzDRSR0NJ5HQknIZdcs/@U6kjmZ0jvOizjVSRr4ZgZkUWRFF/z9XBLMO6mUGMnQY4BYdqFiTAkDvWMogSoCJRrs49pVvH8IbiCvP0z1h@FJNkWn12O@z2xghjHy5oeLhRclQilY8ieYGPwufNK4dhSWXK6IhI5yAzHXs1zC53EhxQB6UAnN2R9pps@9gRyCyPNkFigmHlXw37BrhM/MbxY@R4S5d4k5oRlQdeFtrPQZUkNT7@ME2m2YKkwgTKd4IFOtWFzpwih1oMaNc2dRELIYslIXs8BVmUKqaaK7NU@Me@d1/1DeeETxeRunUsEwQ7loDHNIMAwIl0CCE@iy/PfsdCwKgkisKRg/fDr04iEE1l3osZMhkkCjtLaVyHSE78oxHMLuLsMFhyE864Hf9338SMJXYwwvBAbzCCrrwrsmS0CeC1ux@mscY/rnAsNjLdzvQYeNMY@ot4rO0UpAoyOpvLJpgMRoWkcj76eTC1lQcNFUz3BLc9orXXaxhu6@0emVmr/DfC1D69hvYS4njrHSTd9feGV47xY96CwQ142isjiqxi7GyLnoWKEgDo2fLs2NIzS8GidrPXSInQq9MKGKgmP8Cu@d7VGKDKaT3NiMSpz5iPvyNqX5yWgOrdXEzZ8S52QaSSLXq65F@w46XnU9jvi@1fv3I/V@ksmwmcqoC5T7gFRFmGOv41GsyYZbbgxbdX522U6TeVVFpIlfkLr6Q29RH0JTo5bOTCHAD/iqW@Sf70Jegb0PFF5A59Ai73x7mxne4T9/AP6yML7Bh2tka4/s0ra2kaQxr79H9tUyiJYtxdkJ9/fuT4J0LeBeP92zAnqDgHYC7Uem@5t022R3LOw/UiOVzQ@5LATtulw5g@uXMAvJUSJpFjZ42w@e1JiDZsa8eFJjXjQzpr1F@tkcfbjFeEBrWJ7bT8pRe1uOFrWK9lTm7DQLWe8bGHOa4X5PxojkdwSyJhlzelQamxj00yMNchY0UHm0RdoePTFPRw1peuq4HW0fN5fXx1vQePzEZh//z2g8bk7jjw8yaXuXu490@TeRNC3Azx@p8jTLZw1VwoNUrqKtalzY/@6mGiWZkng/8/AaTfpAJAlcGKWbb0QQu9vsmgtQU7PRGEISdD/b0AKgRDVXcqPG3dzs/XGTgQxpXC/Nw4MqI5HaQuppkRrN9JwX8aXQEqhDUfOCmzVov@uGOOO7q@0Nd1WP6VxtDuH1F65yAY5Dex5XfH33V4WNOhZWoQudadisax816tq4tk21zTT3Ku0Z6vGtC0joxJDULLmUVDeCFCXTWchMUcTqpdMwCIaYI@4elh0DLDWx7WLRZyQgu2Ln13pIHSw1RWQXgb5PTbEUf/y@3/JtPhWQZzGt51sPPY/xzZeUqRXlvMF7riHyzIige9RUyi5l2XWqpzoBBBY@9Gy7SURfbW8KaTgvOwXUmqkxUQl/yr6n0O1Sj8dM1wLONxk3bd36ilOuC8bhKFVhZtNoSwvTFVNf41xxK1bhDZ0XMsIXDBcTMRSJkjw0jNNYjXmQ8e@ih3pEz8oF9GAAq7QxiGegxkRajYJao8IVkgLzqWd4XOHsnuzheMThFlRv4thtX49IwNLySh7yGBefIUWRHzk8G@xz8mkpvclgK6iWBW0rpibDWrFk6CVhty@tCJMXddH6gX3I1nq6mCHTgVnS4fJuFi@FIRC2fF7w35oDwzQQOLGsb6s4fKY@8yRWirUZxhcQVVXLu9vi3v2h1iDTbDoa4yYxmk6ovUybDGSOEKPW8rl6ksrDcqNEAKkrFHv1AHFa3Jn@ttGTY6pTBS5fY11MpXdb7apF2SgNG6X3qUj3tNkBuFQASuDuSvuizsw3EGWgHbDzt5GzTRxgLabz4nTgYQLocJWitGzRq0gtd2o1c17eKixsb6pMsdUkMW/ir1mBvNe@N6mgVNbbl8Jc5UnMWcFfswS39LCcO3KSYLkJsc9Y0rlGlmWXeakU48BOmy8BSJ4ywBZcrr3llmVyw5KIdxdaVCuUc29JOUgs/zh8y3xluTlpsLZbFbdb2j2VmmrtylGHBcojlJNZd8Kh/@ICORd4PDGnHT5Am@YxP1egMRmm0pYWd9xZFq9oseLLB6TlFcslrwsBFzFXwe5Ut7YUGARefJJhtoh0HYA9lNX3yI1i5Yu3UcK@NBvnXRZvFCjTd6NEuetslCi3mpqEnaRvW@d0nKRvXHuFuPJ9/6bf7rfPzvvp2bkH@K@z2@53dvnj2Tn98Ec8bsDOjvnYp58bXLq46Xzv/fAf "Scala ‚Äì Try It Online")
### Explanation
Each pair of columns constitutes a "thread." Threads are executed one at a time, top to bottom, left to right. Each thread also stores a value (initially 0).
Each of **threads 0 and 1** uses the `\/` knot to read a number from stdin and stores that number as its value.
**Thread 2** does the following:
* `[]`: Get the value of thread N, where N is the previous value of this thread. Here, there is no previous value, so we get the value of thread 0.
* `1&`: Push a 1.
* `[]`: Get the value of thread N, where N is the 1 we just pushed.
* `//`: Integer-divide the last two values.
* `/\`: Output the result.
**Thread 3** sets its value to a string containing a newline (`\n`) and then outputs it (`/\`).
**Thread 4** does the same thing as thread 2, but with modulo (`%%`) instead of division.
[Answer]
# [><>](https://esolangs.org/wiki/Fish), ~~27 26~~ 16 + 1 = 17 bytes
```
:r:{%:n','o-$,n;
```
# Note
* Input using the `-v` flag, see TIO for an example.
* This outputs the remainder first, then a comma and lastly the integer division.
[Try it online!](https://tio.run/nexus/fish#@29VZFWtapWnrqOer6uik2f9//9/3TJDYyBhDAA "><> ‚Äì TIO Nexus")
# Explanation
Note that the stack starts as `A, B`, where `A` and `B` represent the first and second input, because of the `-v` flag used.
```
:r:{%:n','o-$,n; # Explanation
:r:{             # Do some stack modifications to prepare it for
                 #    next part
                 #    (Stack: B, A, A, B)
    %            # Take the modulo of the top two items
                 #    (Stack: B, A, A%B)
     :           # Duplicate it
                 #    (Stack: B, A, A%B, A%B)
      n          # Pop once and output as number
                 #    (Stack: B, A, A%B)
       ','o      # Print separator
                 #    (Stack: B, A, A%B)
           -     # Subtract the modulo from the first input
                 #    (Stack: B, A-A%B)
            $,   # Swap the two inputs so they are back in order
                 #     and divide, so we get an integer
                 #    (Stack: floor(A/B))
              n; # Output that as a number and finish.
```
[Answer]
# C, 21 bytes
```
#define f(a,b)a/b,a%b
```
A macro that replaces f(a,b) with the 2 terms comma separated. Though you'd better be passing it to a function or else there's no way to pick the 2 apart.
[Try It Online](https://tio.run/nexus/c-clang#DcdLCoAgEADQtZ5CCkFB@qxaGJ2kjTZKAzWF2So6u/V2r9QQIlIQUTnjtWu9cdKXGmnZbgjjlQGPZp04Uha7Q1L64exMf6OqJAgJM1Umqn4wg9aWsxTynUh0lr/lAw)
[Answer]
# [Haskell](https://www.haskell.org/), 21 bytes
```
a#b=(div a b,mod a b)
```
[Try it online!](https://tio.run/nexus/haskell#@5@onGSrkZJZppCokKSTm58CojX/5yZm5inYKhQUZeaVKKgomJgbGiooK1gYmv4HAA) Example usage: `13#2` returns `(6,1)`. Yes, this is pretty boring, however slightly more interesting than the `divMod` build-in which works the same.
While we are at it, there is also `quot`, `rem` and `quotRem` which behave the same on natural numbers as `div`, `mod` and `divMod`. However, for negative inputs the result of `mod` has the same sign as the divisor, while the result of `rem` has the same sign as the dividend. Or, as it is put in the [Prelude documentation](http://hackage.haskell.org/package/base-4.9.1.0/docs/Prelude.html#v:quot), `quot` is integer division truncated toward zero and `div` is integer division truncated toward negative infinity.
---
How about no `div` or `mod` build-ins?
### No build-ins, ~~36 32~~ 31 bytes
```
a#b|a<b=(a,0)|m<-a-b=(+1)<$>m#b
```
[Try it online!](https://tio.run/nexus/haskell#@5@onFSTaJNkq5GoY6BZk2ujm6gL5Ggbatqo2OUqJ/3PTczMU7BVKCjKzCtRUFEwMjVTtvwPAA "Haskell ‚Äì TIO Nexus") Example usage: `13#2` returns `(1,6)`, that is the `mod` result is first and the `div` result second. If `a` is smaller `b`, then `a mod b` is `a` and `a div b` is `0`, so `(a,0)` is returned. Otherwise recursively compute `mod` and `div` of `a-b` and `b`, add `1` to the division result and keep the remainder.
Adding 1 to the division result is achieved by using `<$>`, which is commonly used as `map` to map functions over lists, but works on tuples too, however the function is applied to the second tuple element only.
Edit: Saved one byte thanks to xnor!
[Answer]
# SWI Prolog, 109 bytes
```
p(A):-print(A).
d(F,S,0,F):-S>F.
d(F,S,D,R):-G is F-S,d(G,S,E,R),D is E+1.
d(F,S):-d(F,S,D,R),p(D),p(-),p(R).
```
Output:
```
?- d(255,25).
10-5
true .
?- d(5,7).
0-5
true .
```
Description:
Simple recursive algorithm without builtin division or modulo. It simply counts "how many times fits the Second number into the First one?" and reports the result (unified to D) with the remainder (R).
//edit: removed unnecessary spaces
]