A Very Big Sum

  • + 7 comments

    What's the reason for using two loops and an array? I feel like that just takes too much time and too much space. Here's my take in C if anyone's interested:

    #include <stdio.h>
    
    int main(void){
        int n;
        long sum=0;
        scanf("%d", &n);
        long value;
        //long arr[n];
        for (int i=0; i < n; i++) {
            scanf("%li", &value);
            sum += value;
        }
        printf("%li", sum);
        return 0;
    }