Consider the following program
int find (int n) { int a = 1; for (i = 1; i < = n; i ++) for (j = 1; j < = i; j++) for (k = 1; k <= j, k++) a = a + 1; return a; }
The value returned by find (9) is ______ .
$\sum_{i=1}^{n}\sum_{j=1}^{i}\sum_{k=1}^{j}1 = \sum_{i=1}^{n}\sum_{j=1}^{i}j = \sum_{i=1}^{n}(i*(i+1)) /2 = 1+3+6+10+15+21+28+36+45 = 165$
Now, initial value of a was 1. Now a value incremented 165 times by 1. So final ans = 1+165 = 166
//https://ide.geeksforgeeks.org/bo7T4PnEfn (If you want to check)
Yes @Shaik Masthan sir this is also one way to do this.