# crt

Chinese remainder theorem

## Syntax

``x = crt(res,div)``

## Description

example

````x = crt(res,div)` returns the scalar integer `x` that is congruent to each remainder in `res` for the corresponding divisor in `div`. `x` satisfies mod(`x`,`div`) = `res`.In other words, dividing `x` by each element of `div` leaves as remainder the corresponding element of `res`.```

## Examples

collapse all

Find a number that has a remainder of `2` when divided by `9`, a remainder of `3` when divided by `10`, and a remainder of `6` when divided by `11`.

`x = crt([2 3 6],[9 10 11])`
```x = 83 ```

Use the `mod` function to verify the result.

`ver = mod(x,[9 10 11])`
```ver = 1×3 2 3 6 ```

In a staggered pulse repetition frequency (PRF) radar system, the first PRF corresponds to `70` range bins and the second PRF corresponds to `85` range bins. The target is detected at bin `47` for the first PRF and bin `12` for the second PRF. Assuming each range bin is `50` meters, compute the target range from these two measurements.

```idx = crt([47 12],[70 85]); r = 50*idx```
```r = 30350 ```

## Input Arguments

collapse all

Remainder array, specified as a row vector of nonnegative integers. `res` must have the same number of elements as `div`.

Data Types: `single` | `double`

Divisor array, specified as a row vector of positive integers. `div` must have the same number of elements as `res`.

Data Types: `single` | `double`

## Output Arguments

collapse all

Congruent integer, returned as a scalar.

## Version History

Introduced in R2021a