I'm having trouble figuring out how to simplify this code to summations since it has an if statement in it.
sum=0
for (i = 1 to n ){
for (j = 1 to i^2){
if (j % i ==0) then
for (k = 1 to j){
sum++
}
}
}
}
I know the if statement will execute i times every loop.
1%1 = 0
2%2 = 0
4%2 = 0
3%3 = 0
6%3 = 0
9%3 = 0
and so on.
This is what I have so far (see link below), forgive the i^2 notation, I can't post images yet without rep. Again, the inner summation is i^2 not 2 choose i.
I want to simplify the inner summation to j, but it only happens, i times. I feel like this is very simple and I am not seeing the obvious connection.
The answer that I marked as correct was wrong. This was the answer that was given to me. I will do my best to say it properly.
The sum from i = 1 to n, of the sum from j = 1 to i squared for even j is equal approximately to the sum from i = 1 to n of i squared times i squared plus one all over 2.
(or the last part again) is equal to approximately:
the sum from i =1 to n of (i^2 * [(i^2) + 1]) / 2 which is Theta n^5.
THIS is the correct answer