Find Missing Number

Find the missing number in a sequence from 1 to n using mathematical sum formula.

Code

Algorithms
echo "$arr" | jq 'length + 1 as $n | ($n * ($n + 1) / 2) - add'

Parameters

Array with one missing number (JSON)

Server

More Bash Snippets