> For the complete documentation index, see [llms.txt](https://calnix.gitbook.io/zk-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://calnix.gitbook.io/zk-notes/zk-puzzles-rareskills/intdivout.md).

# IntDivOut

```solidity
pragma circom 2.1.8;
include "../node_modules/circomlib/circuits/comparators.circom";

// Use the same constraints from IntDiv, but this
// time assign the quotient in `out`. You still need
// to apply the same constraints as IntDiv

template IntDivOut(n) {
    signal input numerator;
    signal input denominator;
    signal output out;

}

component main = IntDivOut(252);
```

{% hint style="info" %}
Remember, **out** is actually an input that the user is expected to provide.
{% endhint %}

### Answer

```solidity
pragma circom 2.1.8;
include "../node_modules/circomlib/circuits/comparators.circom";

template IntDivOut(n) {
    signal input numerator;
    signal input denominator;
    signal output out;

    // compute division
    signal quotient;    
    quotient <-- numerator \ denominator;
    
    // constraint the result of the division to out
    out <== quotient;
}

component main = IntDivOut(252);
```

* we assign and constraint the result of division to out
* therefore, the circuit checks that the value of our provided **out** matches the value of the quotient
* if so, the circuit passes.

{% hint style="warning" %}

* The crucial thing is that the **output signal is part of the witness** - which we are expected to provide.
* **`out`** isn't the consequential output of the division computation.
  {% endhint %}

<details>

<summary>Wrong example (Only computation, no constraint)</summary>

```solidity
template IntDivOut(n) {
    signal input numerator;
    signal input denominator;
    signal output out;

    // compute division
    signal quotient;    
    quotient <-- numerator \ denominator;

    // assign return value to be quotient
    out <-- quotient;
}

component main = IntDivOut(252);
```

* here there are no constraints
* out is assigned the value of division
* circuit will simply return that value

Circuit does not check that the user provided out value matches that of the quotient.

</details>

### Returning: Signal output out

* **`out`** is defined as **`signal output`**
* when we talk about returning **out;** returning a value only applies from circuit to circuit. Not the outside world.
* The circuit can't return a value outside of a circuit setup, to a solidity contract, for example.
* Circuits just evaluate to true or false, depending if your pairing clears.
