Answers for "missing number"

0

missing number

#include <stdio.h>
int main(){
int n;
int total = 0;
printf("How many numbers do you want to enter : ");
scanf("%d",&n);
int i =1;
while(i<=n){
    printf("Enter your number %d : ",i);
    int array;
    scanf("%d",&array);
    total +=array;
    ++i;
}
n++;
int sub = ((n + 1) * (n)) / 2;
printf("%d",(sub-total));
}
Posted by: Guest on June-11-2021
0

missing number

numbers = input("Enter your numbers with ','separated form : ")
int_array = list(map(int,numbers.split(",")))
Sum = 0
for i in range(len(int_array)):
    Sum = Sum+int_array[i]
n = len(int_array) +1
missing = (((n+1) * (n))/2) -Sum 
print(missing)
Posted by: Guest on October-14-2021

Code answers related to "missing number"

Python Answers by Framework

Browse Popular Code Answers by Language