Find Missing Number

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

Code

Algorithms
n = len(arr) + 1
n * (n + 1) // 2 - sum(arr)

Parameters

Array with one missing number

Server

More Python Snippets