Question: I am new to linux. I have a folder with many files in it and i need to get the latest file depending on the file name. Example: I have 3 files `RAT_20190111.txt` `RAT_20190212.txt` `RAT_20190321.txt` . I need a linux command to move the latest file here `RAT20190321.txt` to a specific directory.

Answer: 
Sum of all numbers from 0 to n is 

> 
> n(a1+an)/2 = (in your case a1 = 0 and an = n+1) n\*(n+1)/2
> 
> 
> 

so the missing number is n\*(n+1)/2 - (sum of input numbers after the length)

```
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char* v[]) {
    int length;
    int i = 0;
    int sum = 0;

    scanf_s("%d", &length);

    // calculate arithmetic series sum
    auto series_sum = ((length + 1) * (length)) / 2;

    while (i < length)
    {
        int next;
        scanf_s("%d", &next);

        sum += next;
        ++i;
    }

    printf("missing num is %d ", series_sum - sum);
}

```
The calculation from the question is also correct and can be made to work with a few modifications.

```
#include <stdio.h>
#include <stdlib.h>

int main (int argc, char *v[])  {
    int length;
    int num; 

    // printf("enter maximum number: ");
    scanf("%d", &length);

    int goal=length;
    int i;

    for(i=0; i!=length; i++){
        // printf("number[%d]: ", i);
        if(scanf("%d", &num) != 1) { 
            fprintf(stderr, "invalid input\n");
            return 1;
        }
        if((num < 0) || (num > length)) {
            fprintf(stderr, "invalid number %d\n", num);
            return 2;
        }

        goal=goal+i-num;
    };
    // printf("missing number: ");
    printf("%d\n", goal);
    return 0;
}

```