# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

# `numlib`::`sqrt2cfrac`

Continued fraction expansion of square roots

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

## Syntax

```numlib::sqrt2cfrac(`a`)
```

## Description

`numlib::sqrt2cfrac(a)` returns the continued fraction expansion of the square root of `a` as a sequence of two lists: the first one contains the non-periodic (integer) part, the second one contains the periodic part of the expansion.

## Examples

### Example 1

The square root of 87 can be written as 9 + q, where q is a number satisfying :

`numlib::sqrt2cfrac(87)`

### Example 2

Since 81 is a perfect square, there is no periodic part in the continued fraction expansion of its square root:

`numlib::sqrt2cfrac(81)`

## Parameters

 `a` A positive integer

## Return Values

If `a` is a perfect square, `numlib::sqrt2cfrac` returns a list with one entry; otherwise `numlib::sqrt2cfrac` returns a sequence of two lists, the first consisting of one integer, the second consisting of one or more integers.