public long seriesLoop() {
long answer = a;
for (long i = 1; i < n; i++) {
long delta = a;
for (long j = 0; j < i; j++) {
delta *= r;
}
answer += delta;
}
return answer;
}
public long seriesClosedForm() {
return (long) (a * (1 - Math.pow(r, n)) / (1 - r));
}
What is the Big-O notation for these 2 methods? Why? How do we calculate the big-O of an algorithm?