def get_missing_summatin(a):
n = a[-1]
total = n*(n+1)//2
summation = 0
summation = sum(a)
result = total-summation
print(result)
a = [1,2,3,5,6,7]
get_missing_summatin(a)
// Java program to find missing Number
import java.util.*;
import java.util.Arrays;
class GFG {
// Function to find the missing number
public static int getMissingNo(int[] nums, int n)
{
int sum = ((n + 1) * (n + 2)) / 2;
for (int i = 0; i < n; i++)
sum -= nums[i];
return sum;
}
// Driver code
public static void main(String[] args)
{
int[] arr = { 1, 2, 3, 5 };
int N = arr.length;
System.out.println(getMissingNo(arr, N));
}
}
const findMissing = num => {
const max = Math.max(...num); // Will find highest number
const min = Math.min(...num); // Will find lowest number
const missing = []
for(let i=min; i<= max; i++) {
if(!num.includes(i)) { // Checking whether i(current value) present in num(argument)
missing.push(i); // Adding numbers which are not in num(argument) array
}
}
return missing;
}
findMissing([1,10,5,41,35,26,2,15,34,44,12,46,49,50,14, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27,]);