An abundant number is a natural number that is less than the sum of its proper divisors. For example `12 < 1+2+3+4+6=16`

so 12 is an abundant number, while `16 > 1+2+4+8=15`

is not an abundant number.
I have to write a program in C language so that for the input k, the output are all abundant numbers less than or equal to k.

I'm only a beginner at this so what I first wanted to do is to write a program that will check whether k is abundant or not. So this is what I did:

```
#include <stdio.h>
int main(void) {
int k, i, s = 0;
scanf("%d", &k);
for (i = 1; i < k; i++) {
if (k % i == 0)
s = s + i;
}
if (k < s)
printf("%d" is an abundant number", k);
return 0;
}
```

Feel free to ignore this above, I only wanted to show you I actually tried something by myself. Now I wasn't sure how to make this program list the abundant numbers that are also less than `k`

, but I found the solution which I don't understand:

```
#include <stdio.h>
int main(void) {
int k, i, j, s;
scanf("%d", &k);
for (i = 1; i <= k; i++) {
s = 0;
for (j = 1; j < i; j++) {
if (i % j == 0)
s = s + j:
}
if (i < s)
printf("%d"\n", i);
}
return 0;
}
```

I'm confused by this nested for loop, can someone explain exactly how it works? For instance if we put k=18, what exactly happens with this for loops so that in the end we get 12 and 18 as output?