[Question]
  [
## Challenge
Given a positive integer \$n\$, count the number of \$n\times n\$ binary matrices (i.e. whose entries are \$0\$ or \$1\$) with exactly two \$1\$'s in each rows and two \$1\$'s in each column.
Here are a few examples of valid matrices for \$n=4\$:
```
1100        1100        1100        
1100        0011        0110        
0011        1100        0011        
0011        0011        1001        
```
And here are a few invalid matrices:
```
1100
0011
0111    <-- three 1's in this row
1100
 ^
 `--- three 1's in this column
```
```
1111    <-- four 1's in this row
0011
1100
0000    <-- zero 1's in this row
```
This sequence is catalogued on OEIS as [A001499](https://oeis.org/A001499). Here are a few non-bruteforce ways to compute it (\$a\_n\$ denotes the number of valid \$n\times n\$ binary matrices).
* The recursive formula
$$
2a\_n-2n(n-1)a\_{n-1}-n(n-1)^2a\_{n-2}=0
$$
with base cases \$a\_1=0\$, \$a\_2=1\$.
* The explicit formula
$$
a\_n=\frac{(n!)^2}{4^n}\sum\_{i=0}^n\frac{(-2)^i(2n-2i)!}{i!((n-i)!)^2}.
$$
You may find other ways to compute this sequence on the OEIS page linked above. To be clear, bruteforcing is a perfectly valid way of solving this challenge.
## Rules
As usual in [sequence](/questions/tagged/sequence "show questions tagged 'sequence'") challenges, your task is to write a program/function which does one of the following (consistently across different inputs).
* Take a positive integer \$n\$ as input and return \$a\_n\$ as output. Because of the combinatorial interpretation of this sequence, it has to be \$1\$-indexed (i.e. you are not allowed to take \$n\$ and return \$a\_{n+1}\$). If you choose this option, you are not required to handle the input \$n=0\$.
* Take a positive integer \$n\$ as input and return the list \$[a\_1,a\_2,\ldots,a\_n]\$ as output. Optionally, you may instead choose to return \$[a\_0,a\_1,\ldots,a\_{n-1}]\$ or \$[a\_0,a\_1,\ldots,a\_n]\$, where \$a\_0=1\$ (consistent with the combinatorial interpretation). The choice has to be consistent across different inputs.
* Take no input and return the infinite list/generator \$[a\_1,a\_2,a\_3,\ldots]\$. Optionally, you may instead choose to return \$[a\_0,a\_1,a\_2,\ldots]\$, where \$a\_0=1\$.
Your program/function must theoretically work for arbitrarily large inputs, assuming infinite time, memory and integer/floating point precision. In practice, it's ok if if fails because of integer overflow and/or floating point errors.
# Scoring
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest code in bytes wins.
## Testcases
```
Input                     Output
 1                             0
 2                             1
 3                             6
 4                            90
 5                          2040
 6                         67950
 7                       3110940
 8                     187530840
 9                   14398171200
10                 1371785398200
11               158815387962000
12             21959547410077200
13           3574340599104475200
14         676508133623135814000
15      147320988741542099484000
```
  
[Answer]
# [J](http://jsoftware.com/), 41 bytes
```
1#.*:=1#.2>[:>@~.@,[:+&,&.>/~i.@!<@A.=@i.
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/DZX1tKxsgaSRXbSVnUOdnoNOtJW2mo6anp1@Xaaeg6KNg6OerUOm3n9NrtTkjHygVluFNAVDCMcQzDGCcMzAHGMIxxKizgTCMzIwgfBNoUrNLU0hAmb/AQ "J – Try It Online")
A different take on brute force, which handles up to n=6 on TIO.
Since the idea is more interesting than the J mechanics here, I'll explain that.
I could likely save bytes by translating one of the formulas into J, but that seemed less fun.
## the idea
* Generate all `n!` permutations of the identity matrix. Eg, for n=3:
```
┌─────┬─────┬─────┬─────┬─────┬─────┐
│1 0 0│1 0 0│0 1 0│0 1 0│0 0 1│0 0 1│
│0 1 0│0 0 1│1 0 0│0 0 1│1 0 0│0 1 0│
│0 0 1│0 1 0│0 0 1│1 0 0│0 1 0│1 0 0│
└─────┴─────┴─────┴─────┴─────┴─────┘
```
* Create an "addition table" of this list with itself, using matrix addition:
```
┌─────┬─────┬─────┬─────┬─────┬─────┐
│2 0 0│2 0 0│1 1 0│1 1 0│1 0 1│1 0 1│
│0 2 0│0 1 1│1 1 0│0 1 1│1 1 0│0 2 0│
│0 0 2│0 1 1│0 0 2│1 0 1│0 1 1│1 0 1│
├─────┼─────┼─────┼─────┼─────┼─────┤
│2 0 0│2 0 0│1 1 0│1 1 0│1 0 1│1 0 1│
│0 1 1│0 0 2│1 0 1│0 0 2│1 0 1│0 1 1│
│0 1 1│0 2 0│0 1 1│1 1 0│0 2 0│1 1 0│
├─────┼─────┼─────┼─────┼─────┼─────┤
│1 1 0│1 1 0│0 2 0│0 2 0│0 1 1│0 1 1│
│1 1 0│1 0 1│2 0 0│1 0 1│2 0 0│1 1 0│
│0 0 2│0 1 1│0 0 2│1 0 1│0 1 1│1 0 1│
├─────┼─────┼─────┼─────┼─────┼─────┤
│1 1 0│1 1 0│0 2 0│0 2 0│0 1 1│0 1 1│
│0 1 1│0 0 2│1 0 1│0 0 2│1 0 1│0 1 1│
│1 0 1│1 1 0│1 0 1│2 0 0│1 1 0│2 0 0│
├─────┼─────┼─────┼─────┼─────┼─────┤
│1 0 1│1 0 1│0 1 1│0 1 1│0 0 2│0 0 2│
│1 1 0│1 0 1│2 0 0│1 0 1│2 0 0│1 1 0│
│0 1 1│0 2 0│0 1 1│1 1 0│0 2 0│1 1 0│
├─────┼─────┼─────┼─────┼─────┼─────┤
│1 0 1│1 0 1│0 1 1│0 1 1│0 0 2│0 0 2│
│0 2 0│0 1 1│1 1 0│0 1 1│1 1 0│0 2 0│
│1 0 1│1 1 0│1 0 1│2 0 0│1 1 0│2 0 0│
└─────┴─────┴─────┴─────┴─────┴─────┘
```
* Now we note that the valid items are simply those without a 2 anywhere:
```
┌─────┬─────┬─────┬─────┬─────┬─────┐
│     │     │     │1 1 0│1 0 1│     │
│     │     │     │0 1 1│1 1 0│     │
│     │     │     │1 0 1│0 1 1│     │
├─────┼─────┼─────┼─────┼─────┼─────┤
│     │     │1 1 0│     │     │1 0 1│
│     │     │1 0 1│     │     │0 1 1│
│     │     │0 1 1│     │     │1 1 0│
├─────┼─────┼─────┼─────┼─────┼─────┤
│     │1 1 0│     │     │     │0 1 1│
│     │1 0 1│     │     │     │1 1 0│
│     │0 1 1│     │     │     │1 0 1│
├─────┼─────┼─────┼─────┼─────┼─────┤
│1 1 0│     │     │     │0 1 1│     │
│0 1 1│     │     │     │1 0 1│     │
│1 0 1│     │     │     │1 1 0│     │
├─────┼─────┼─────┼─────┼─────┼─────┤
│1 0 1│     │     │0 1 1│     │     │
│1 1 0│     │     │1 0 1│     │     │
│0 1 1│     │     │1 1 0│     │     │
├─────┼─────┼─────┼─────┼─────┼─────┤
│     │1 0 1│0 1 1│     │     │     │
│     │0 1 1│1 1 0│     │     │     │
│     │1 1 0│1 0 1│     │     │     │
└─────┴─────┴─────┴─────┴─────┴─────┘
```
* But these are not necessarily unique. However, after removing dups, we
have our answer, which is 6:
```
┌─────┬─────┬─────┬─────┬─────┬─────┐
│     │     │     │1 1 0│1 0 1│     │
│     │     │     │0 1 1│1 1 0│     │
│     │     │     │1 0 1│0 1 1│     │
├─────┼─────┼─────┼─────┼─────┼─────┤
│     │     │1 1 0│     │     │1 0 1│
│     │     │1 0 1│     │     │0 1 1│
│     │     │0 1 1│     │     │1 1 0│
├─────┼─────┼─────┼─────┼─────┼─────┤
│     │     │     │     │     │0 1 1│
│     │     │     │     │     │1 1 0│
│     │     │     │     │     │1 0 1│
├─────┼─────┼─────┼─────┼─────┼─────┤
│     │     │     │     │0 1 1│     │
│     │     │     │     │1 0 1│     │
│     │     │     │     │1 1 0│     │
├─────┼─────┼─────┼─────┼─────┼─────┤
│     │     │     │     │     │     │
│     │     │     │     │     │     │
│     │     │     │     │     │     │
├─────┼─────┼─────┼─────┼─────┼─────┤
│     │     │     │     │     │     │
│     │     │     │     │     │     │
│     │     │     │     │     │     │
└─────┴─────┴─────┴─────┴─────┴─────┘
```
[Answer]
# JavaScript (ES6), 36 bytes
Returns the \$n\$th term of the sequence.
```
f=n=>--n<2?n:-~n*n*(f(n)+n*f(n-1)/2)
```
[Try it online!](https://tio.run/##FctBDoIwEAXQPaf4y07rqGUpVM9CkBoN@WOAuDF49YKrt3qv7tPN/fR8L0q7D6XkxHRVZVvfeNEfPb3LjhLodzTKqZaSbXJEQmxAtIjn3RAE3wrojbONw3G0h@MB/ytNtZYN "JavaScript (Node.js) – Try It Online")
### How?
We decrement \$n\$ right away in order to use the following 0-indexed form of the recursive formula:
* \$a\_n=n\$ for \$0\le n< 2\$
* \$a\_n=(n+1)\times n\times \left(a\_{n-1}+\dfrac{n\times a\_{n-2}}{2}\right)\$ for \$n\ge2\$
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~17~~ 12 bytes
```
1ÝλsN*;+NN>P
```
[Try it online!](https://tio.run/##yy9OTMpM/f/f8PDcc7uL/bSstf387AL@/wcA "05AB1E – Try It Online")
-4 thanks to @ovs, which allowed for another -1
Uses the recursive formula.
```
1Ý        0-based range from 1, pushes [0,1]
λ         recursive context
 s        swap the implicit a(n-1),a(n-2) to a(n-2),a(n-1)
 N*       n*a(n-2)
 ;        /2
 +        +a(n-1)
 NN>      n,(n+1)
 P        product of all elements in stack, (n*a(n-2)/2+a(n-1))*n*(n+1)
```
[Answer]
# [Oasis](https://github.com/Adriandmen/Oasis), ~~16 12 14 13~~ 11 bytes
```
àn*t+nn>**T
```
[Try it online!](https://tio.run/##y08sziz@///wgjytEu28PDstrZD////r@v83AgA "Oasis – Try It Online")
Uses the recursive formula, a port of the 05AB1E answer.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 15 bytes
```
²Ø.ṗs€µ;Z§=2Ạ)S
```
[Try it online!](https://tio.run/##ATgAx/9qZWxsef//wrLDmC7huZdz4oKswrU7WsKnPTLhuqApU/874oCcIC0@IOKAnTvDhwo0w4figqxZ/w "Jelly – Try It Online")
A monadic link taking an integer and returning an integer. Brute forces it.
## Explanation
```
²               | Squared
 Ø.ṗ            | [0,1] Cartesian power of this
    s€          | Split each of these into lists of the original argument in length
      µ         | Start a new monadic chain
             )  | For each of the possible matrices we’ve generated:
       ;Z       | - Append its transpose
         §      | - Sum each list
          =2    | - Equal to 2 (vectorises)
            Ạ   | - All true
              S | Finally, sum to find the number of matrices meeting the criteria
```
---
As an alternative, here’s an implementation of the recursive formula:
# [Jelly](https://github.com/DennisMitchell/jelly), 18 bytes
```
L,²H$×‘Ʋ×Fḣ2S;
Ç¡Ḋ
```
[Try it online!](https://tio.run/##ASgA1/9qZWxsef//TCzCskgkw5figJjGssOXRuG4ozJTOwrDh8Kh4biK//80 "Jelly – Try It Online")
A full program that takes n via STDIN and returns the first `n+1` terms in reverse order. I thought I should be able to shorten it by replacing `\nÇ` with `µ` but that’s not working.
---
Finally, a Jelly translation of @Jonah’s J answer:
# [Jelly](https://github.com/DennisMitchell/jelly), 15 bytes
```
=þ`Œ!+þ`ẎQ«Ƒ€1S
```
[Try it online!](https://tio.run/##y0rNyan8/9/28L6Eo5MUtYHUw119gYdWH5v4qGmNYfD///9NAQ "Jelly – Try It Online")
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~45~~ 41 bytes
```
f(n){n=n--<3?n:-~n*n*(f(n)+n*f(n-1)/2.);}
```
[Try it online!](https://tio.run/##VVDbboMwDH3nKyykSgkkK5dexCjbw7SvGDygEDrUza1IpaEh9uljhlK6RortHJ/j5ETJvVJ9XzLkLSYo5S58xkf5gw46bEBddChJny@DBx53fYVn@MwrZNxqLaA1ALo5aXXWxVsGCbSeAF/ARkBEVeCtKG620ZpS6PtetPK6eFSq97x2KGp10DVJYRDbafMapE30QnttC/h/Du1JWR5rYMPFFRa6IZkXT@UOTPWtjyW7PokvJ8CZkRhcd2RzuFi42kCadBnjgh/ftQy1hu@4RzWhs/dRmd0Ip5ooJbMXBcgnoLgwKZIjFGDEbFsnicmmsZ3V9b@q/Mj3ppdffw "C (gcc) – Try It Online")
Inputs a positive integer \$n\$ and returns \$a\_n\$.
[Answer]
# [Factor](https://factorcode.org/), ~~83~~ 76 bytes
```
:: f ( n! -- m ) n 1 - n! n n 1 > [ n 1 + * n f n n 1 - f 2 / * + * ] when ;
```
[Try it online!](https://tio.run/##Lcu9DoIwFAXg3ac4bv4Vg4lLSVwNC4txIgy1uQViucVSY3z6WojTOffLuUbp4Hy838rqKmGdVnbCoEKHJ3kmi4leb2JNE0ZPIXxH33NYFplX3CYvVmUl0TpropQw2IDXEAIDtmDkEPPNS72gXnKPXUrzV5HaCcdkszf4dMQoYn5GnR8eTfoxyJKT0l38AQ "Factor – Try It Online")
*-7 thanks to @Delfad0r*
This is a translation of [@Arnauld's excellent answer](https://codegolf.stackexchange.com/a/225706/97916).
This is the first time I've submitted a Factor golf where it was shortest to make a named function. Recursion is so much shorter than other solutions that the mandatory function signature is worth it.
Here are some other solutions I tried first, which ended up being longer:
**Brute force, 94 bytes**
```
[ { 0 1 } swap '[ _ selections ] twice [ dup flip [ t [ sum 2 = and ] reduce ] both? ] count ]
```
**Explicit formula, 98 bytes**
```
[| n | n n! sq 4 n ^ / n [0,b] [| i | -2 i ^ 2 n * 2 i * - n! * i n! n i - n! sq * / ] map-sum * ]
```
[Answer]
# [APL(Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), 32 bytes [SBCS](https://github.com/abrudz/SBCS)
```
{+/∧/¨(2=+/,+⌿)¨⍵ ⍵∘⍴¨↓⍉⊤⍳2*×⍨⍵}
```
[Try it on APLgolf!](https://razetime.github.io/APLgolf/?h=e9Q31dP/UdsEAwA&c=q9bWf9SxXP/QCg0jW219He1HPfs1D6141LtVAYgfdcx41LsFyG2b/Ki381HXkke9m420Dk9/1AtSUQsA&f=AwA&i=Szu04lHvZhMA&r=tio&l=apl-dyalog-extended&m=dfn&n=f)
A dfn submission which takes a single input on the right.
Straight brute force which exceeds workspace size at n=5.
Uses `⎕IO←0` (0 indexing).
-4 bytes from ovs.
## Explanation
```
{+/∧/¨(2=+/,+⌿)¨⍵ ⍵∘⍴¨↓⍉2⊤¯1+⍳2*×⍨⍵}
                                2*×⍨⍵ 2^(n**2)
                            ¯1+⍳        0-range
                          2⊤           convert to base 2 matrix
                        ⍉              transpose
                       ↓                convert to nested list
                ⍵ ⍵∘⍴¨                 reshape each vector to n x n matrix
      (2=+/,+⌿)¨                        2= sums of rows and cols?
   ∧/¨                                 check if all elements of each satisfy that condition
 +/                                    sum
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 15 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
⁼þⱮŒ!+þ`ẎḊỊÐṀQL
```
A monadic Link that accepts \$n\$ and yields \$a\_n\$.
**[Try it online!](https://tio.run/##ASoA1f9qZWxsef//4oG8w77isa7FkiErw75g4bqO4biK4buKw5DhuYBRTP///zQ "Jelly – Try It Online")**
### How?
Uses [Jonah's](https://codegolf.stackexchange.com/users/15469/jonah) idea from their [J answer](https://codegolf.stackexchange.com/a/225721/53748).
```
⁼þⱮŒ!+þ`ẎḊỊÐṀQL - Link: n
   Œ!           - all permutations (of implicit [1..n])
  Ɱ             - map with:
 þ              -   (implicit [1..n]) outer product (permutation) using:
⁼               -     equals?
       `        - use that as both arguments of:
      þ         -   outer product using:
     +          -     addition
        Ẏ       - tighten (to a list of matrices)
         Ḋ      - dequeue (makes the following still work when n=1)
           ÐṀ   - keep those which are maximal under:
          Ị     -   is insignificant (abs(x)<=1?)
             Q  - deduplicate
              L - length
```
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), ~~49~~ 36 bytes
```
⊞υ¹⊞υ⁰Ｆ⊖Ｎ⊞υ×÷×Ｌυ⊖Ｌυ²⁺⊗§υ±¹×⊖Ｌυ§υ±²Ｉυ
```
[Try it online!](https://tio.run/##bY7LCsIwEEX3fkWWU4ggxZ0rn1CwUvQLYjs0gXT6SFL9@5jU58JZhMmdy7m3lGIoW6G9z6hz9uSaKw7QJ6vZ2hhVExyUtkHJRQdFewtbylmfcJa3ldMtZGR3alQVguLsYzgLqhEW0ZkEbxqffe@ENvF6cQ2o6SBDTjEosrAVxsIRqbbyHfmkvTSZPGO/lFzcVRNIG2EQIjJW7Dmb/mubUYV3kJz9afjD1FOPjMoBGySLFcTK/6QwK@@Xfj7qBw "Charcoal – Try It Online") Link is to verbose version of code. Outputs the terms `a₀..aₙ`. Explanation:
```
⊞υ¹⊞υ⁰Ｆ⊖Ｎ⊞υ×÷×Ｌυ⊖Ｌυ²⁺⊗§υ±¹×⊖Ｌυ§υ±²Ｉυ
```
Start with `a₀` and `a₁`.
```
Ｆ⊖Ｎ
```
Input `n` and calculate `n-1` more terms...
```
⊞υ×÷×Ｌυ⊖Ｌυ²⁺⊗§υ±¹×⊖Ｌυ§υ±²
```
... apply the recurrence relation to calculate the next term.
```
Ｉυ
```
Output all the terms.
[Answer]
# MATLAB/Octave, 58 bytes
```
c=0
b=1
n=2;while k=n
n=n+1;
a=n*k*b+n*k*k*c/2
c=b;b=a;end
```
[Use Octave Online to test it yourself!](https://octave-online.net/) TIO seems to have problems with infinite nature of the script. It uses recursive formula and it's an infinite generator. The following results are printed to the console. It technically works forever but pretty fast falls into limits of floating precision and all new results are infinity. On MATLAB as I checked the results stay precise up to 13th element of the sequence. After that some floating precision errors appear and then they accumulate with each next element.  
The scripts throws a warning due to `while k=n` but it continues to work. If needed to be avoided it can be replaced with `while 1` and `k=n` in next line.
For MATLAB it is also possible to reduce length to **57 bytes** with code like that:
```
c=0
b=1
for n=3:Inf
k=(n-1);a=n*k*b+n*k*k*c/2
c=b;b=a;end
```
But it doesn't work in Octave due to `3:Inf` range.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 15 bytes
```
’ÑH×+Ñ××‘
’¹ÇỊ?
```
[Try it online!](https://tio.run/##AS4A0f9qZWxsef//4oCZw5FIw5crw5HDl8OX4oCYCuKAmcK5w4fhu4o//zhSw4figqz/ "Jelly – Try It Online")
Uses the recursive formula.
## Explanation
```
’ÑH×+Ñ××‘ Auxiliary monadic link, taking (n-1) as the argument
’         Decrement:
                (n-2)
 Ñ        Apply next link:
                a(n-2)
  H       Halve:
                a(n-2) / 2
   ×      Multiply by the argument:
                (n-1) a(n-2) / 2
    +     Add
     Ñ      the next link applied to the argument:
                (n-1) a(n-2) / 2 + a(n-1)
      ×   Multiply by the argument:
                (n-1) ((n-1) a(n-2) / 2 + a(n-1))
       ×  Multiply by
        ‘   the argument incremented:
                n (n-1) ((n-1) a(n-2) / 2 + a(n-1))
’¹ÇỊ? Main monadic link, taking n as the argument
’     Decrement: (n-1)
    ? If
   Ị    insignificant: |n-1| ≤ 1
      then
 ¹      identity: (n-1)
      else
  Ç     apply previous link
```
[Answer]
# [R](https://www.r-project.org/), 52 bytes
```
f=function(n,k=n-1)"if"(n<3,k,n*k*(f(k)+f(n-2)*k/2))
```
[Try it online!](https://tio.run/##BcFBCoAgEAXQu7iaMSW0RRB5jS4gDsjAF8Q2XX56b5pJkRd19QFC0IKY2HVxhPsIGuDVk5DyJoSY2eueme1pdY3Zv0bClK6T7Qc "R – Try It Online")
Using formula from [OEIS page](https://oeis.org/A001499): `a(n) = n(n-1)/2 [ 2 a(n-1) + (n-1) a(n-2) ] (Bricard)`
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 20 bytes
```
~lṁ{{0|1}ᵐ²\,?+ᵐ=₂}ᶜ
```
Brute-force solution; times out on TIO with any input higher than 4. [Try it online!](https://tio.run/##SypKTM6ozMlPN/r/vy7n4c7G6mqDGsPah1snHNoUo2OvDWTYPmpqqn24bc7//yb/IwA "Brachylog – Try It Online")
### Explanation
```
~l                    Generate a list whose length equals the input
  ṁ                   That list is a square matrix
                      At this point, we have a matrix of indeterminate values
   {              }ᶜ  Count how many ways we can satisfy this predicate:
    {   }ᵐ²            For each value in the matrix:
     0|1                It is either 0 or 1
           \           Transpose the matrix
            ,?         Append the non-transposed version
                       We now have a list of all rows and all columns of the matrix
              +ᵐ       Sum each row/column
                =₂     All the results must equal 2
```
[Answer]
# [Pari/GP](http://pari.math.u-bordeaux.fr/), 48 bytes
```
a(n)=if(n<2,n<1,(n^2-n)*(a(n-1)+(n-1)/2*a(n-2)))
```
[Try it online!](https://tio.run/##K0gsytRNL/j/P1EjT9M2M00jz8ZIJ8/GUEcjL85IN09TSwMooWuoqQ0m9Y20QFwjTU3N//8LijLzSoDSxpqaAA "Pari/GP – Try It Online")
Found it on the OEIS page, just golfed it a bit, uses Recursion
[Answer]
# [Python 3](https://docs.python.org/3/), 53 bytes
```
a=lambda n:n<1if n<2else~-n*n*(a(n-1)+(n-1)/2*a(n-2))
```
[Try it online!](https://tio.run/##K6gsycjPM/7/P9E2JzE3KSVRIc8qz8YwM00hz8YoNac4tU43TytPSyNRI0/XUFMbTOobaYG4Rpqa/wuKMvNKgJLGQDYA "Python 3 – Try It Online")
-2 thanks to @Neil
Recursive formula, for input 1 it should output `False` instead of 0
[Answer]
# [Desmos](https://desmos.com/calculator), 51 bytes
```
a=n-i
f(n)=n!^2/4^n\sum_{i=0}^n(-2)^i(2a)!/(i!a!^2)
```
[Try It On Desmos!](https://www.desmos.com/calculator/rlkrjftol0)
[Try It On Desmos!(Prettified)](https://www.desmos.com/calculator/zl1o4zuikq)
Desmos doesn't support recursion and has limited ability for loops, so I had to use the explicit formula:
$$a\_n=\frac{(n!)^2}{4^n}\sum\_{i=0}^n\frac{(-2)^i(2n-2i)!}{i!((n-i)!)^2}$$
[Answer]
# [Ruby](https://www.ruby-lang.org/), 41 bytes
```
f=->n{(w=n*n-=1)<3?n:w*f[n]+w*n*f[n-1]/2}
```
[Try it online!](https://tio.run/##KypNqvz/P81W1y6vWqPcNk8rT9fWUNPG2D7PqlwrLTovVrtcKw/E0DWM1Teq/V@goGGop2dooKmXm1igoZam@R8A "Ruby – Try It Online")
Using the recursive formula
[Answer]
# [Python 3](https://docs.python.org/3/), 195 bytes
```
def f(n):
  if n<2:
    return 1
  return n*f(n-1)
def o(n):
  if n < 2:
    return 0
  p=0
  r=(f(n)**2)/4
  for i in range(n+1):
    p+=(-2)**i*f(2*n-2*i)/(f(i)*(f(n-i)**2))
  return int(p * r)
```
[Try it online!](https://tio.run/##XY7LCsJADEX3/YosJylD7agI0n6MYEezyQyhLvz6MVHwtQk3cM9J6n29Ftm2dl4y5CB47AA4g0zJE4Au600Fxu4dhawXR@wcKV8ITPALbWyps0@dg8uJEg4723NRYGABPcllCdKP@CJrP4eYrMh2JZHERIyDwYzkishPCX7eYVlDBQLF9mc97F1a1RvFBNge "Python 3 – Try It Online")
Pretty ungolfed, but hey, it's one of the first to use the standard formula, and it can handle up to 75.
]