# squares_r function

How many ways a whole number is a sum of a given count of squares, counting order and signs.

## How to write it

### squares_r(d, n)

**d**

How many squares. Takes a whole number.

**n**

The number to write as a sum. Takes a whole number.

## Examples

- $\displaystyle \operatorname{squares\_r}(2, 5) = 8$

  `squares_r(2, 5)`

  In the solver, `squares_r(2, 5)` gives `8`.

  [Open in the solver](https://hilberon.com/?q=squares_r%282%2C%205%29)

## Related functions

- [stirling_s1](https://hilberon.com/library/stirling_s1)

  Stirling number of the first kind, with sign.
- [solve_congruence](https://hilberon.com/library/solve_congruence)

  Solve a congruence for a variable.
- [stirling_s2](https://hilberon.com/library/stirling_s2)

  Stirling number of the second kind: the ways to split n items into k groups.
- [primitive_root](https://hilberon.com/library/primitive_root)

  A primitive root of a prime: a number whose powers cover all the nonzero residues.
- [subfactorial](https://hilberon.com/library/subfactorial)

  Subfactorial: how many ways to reorder n items so none stays in place.
- [prime_pi](https://hilberon.com/library/prime_pi)

  How many primes are at most a number.

---
Source: https://hilberon.com/library/squares_r
