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: 
You have `n` number of integers to be scanned. Use mathematical equation to calculate the [sum of first `n+1` natural numbers](https://en.wikipedia.org/wiki/1_%2B_2_%2B_3_%2B_4_%2B_%E2%8B%AF). Then run a loop for `n` times and then run a loop to add all the `n` numbers scanned. Then subtract this sum with the sum of `n+1` natural number. Result will be the missing number.
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;
}

```