# math.range()

The `math.range()` function returns the range of numbers.

{% code lineNumbers="true" %}

```scss
// Sass.
@use 'sass:list';

// Functions.
@use '../meta/meta.of-type.function';

// Modules.
@use 'range';

// The `math.range()` function.
@function range($from, $to, $step: 1, $except: null, $separator: auto) {
  @return if(
    meta.of-type(number, $from, $to, $step),
    if(
      $from < $to,
      range.up($from, $to, $step, $except, $separator),
      range.down($from, $to, $step, $except, $separator)
    ),
    null
  );
}
```

{% endcode %}

{% embed url="<https://github.com/angular-package/sass/blob/main/math/_math.range.function.scss>" %}

### Parameters

#### **`$from`**

The value of the `number` type indicates the beginning of the range.

#### **`$to`**

The value of `number` type indicates the end of the range.

#### **`$step: 1`**

The value of `number` type indicates each increment of the range. By default, it's **`1`**.

#### **`$except: null`**&#x20;

The value of a `number` or `list` of numbers not belonging to the range.

#### `$separator: auto`

A separator between the given range numbers.

### Return

The return value is the `list` of numbers from the given range.

## Examples

```scss
// Use.
@use '@angular-package/sass/math';

// Examples.
@debug math.range(15, 20); // 15 16 17 18 19 20
@debug math.range(20, 15); // 20 19 18 17 16 15

// step 2
@debug math.range(15, 20, 2); // 15 17 19

// to lower step 2
@debug math.range(15, -3, 2); // 15 13 11 9 7 5 3 1 -1 -3

// except
@debug math.range(15, -3, 1, 0); // 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 -1 -2 -3
@debug math.range(15, -3, 1, 0 15 14); // 13 12 11 10 9 8 7 6 5 4 3 2 1 -1 -2 -3

// separator
@debug math.range(15, -3, 3, $separator: comma); // 15, 12, 9, 6, 3, 0, -3

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.angular-package.dev/sass/math/math.range.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
