All algorithms, regardless of input size, are O(∞).
The following is O(∞).
function :
return 2;
Big-O denotes an upper bound. It's often assumed that it's the "best" upper bound, and most text/literature uses it in this way, but it isn't something that's given to you automatically by using big-O. If f(x) is O(g(x)), we know that f(x) is bounded above by g(x), but we don't know that it's bounded above. If f(x) is Theta(g(x)), then it's bounded both above and below by g(x). Big-O is used in place of big-Theta often because it's harder to prove a big-Omega (bounded below by) bound, and it isn't particularly useful for most things.