0

The objective is to add all the prime numbers before an arbitrary input. I am wondering what exactly this person has done through this code. I am not this advanced, and I do not how to work with particularly the int[] a variable. What is the int[] a command called? Could you please teach me how to write it without the int[] a variable? My life would be indebted to whomever helps me out.

```
int n;
int i, j, sum;
int[] a;
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
sum = 0;
a = new int[n];
for (i = 2; i < n; ++i)
a[i] = i;
for (i = 2; i < n; ++i) {
if (a[i] != 0) {
sum += a[i];
for (j = 2 * i; j < n; j += i)
a[j] = 0;
}
}
System.out.println("The sum of all primes up to " + n + " is " + sum);
```