I am just starting out in a data structure class, and the instructors have posted 10 problems and asked the Big O of one of them. Based off the posts I have read I am assuming that the Big O of this code would be O(1), since the data parameter is a single data element. However, it does execute multiple times depending on the size of the number so would that make it O(N)?
public class Main {
public static void main(String[] args) {
f(100000);
}
public static long f (int n) {
long sum = 0;
for (long i = 2; i < n; i = i * i) {
sum += i;
System.out.println(sum);
}
return sum;
} // end f
}