Why is this code from the lesson in Java?

@mtf, Why is this code from the lesson in Java(I recognized it because I’ve seen Java code):

public class Main() { void int addUpTo(int n) { int total = 0; for (int i = 1; i <= n; i++) { total += i; } return total; } }


Looks like C++, also. Cannot say why it would be in there. What would Big O be for that function?

1 Like

Is it actually C++? Do you know C++? When I looked in the C++ Get Help section I didn’t see you participating. What about I learn it.

I think it’s O(N). It’s also Omega(1).

Not in any real purposeful way. I’m a tinkerer, now, and C flavors, including Java are not in my wheelhouse. JS and Python are enough to suit my needs. Python is so well developed at this stage it might be the only language you will ever need. However, depending on your ambitions, C++ might be something you will require in your profession. Let the need arise, first, before embarking. Circle back over Python and perfect that language. A lot of what you will be/are learning has overlap with C++ which is what the original Python was written in. Today, I believe a lot of Python is now written in Python.

Node.js is also very much overlapping with C++, so there is a value in knowing the language if you are really intent on using it. Stick to what you are learning, at present, and let the future help determine your next course.


I might not learn C++ next. I might learn a language that starts with C but is not C.

That leaves one really guessing given there must be over 70 languages that start with C. COBOL was a popular language decades ago, though it is business oriented, not science, as such.

I mean one that is starting with C and has 2 characters.

C-sharp, then?

Note: This topic was split off from the FAQ as it really shouldn’t have been there, apart from the lesson, that is. We can still go back and can come forward.