Repository: sympy/sympy

Issue:
very simple example of series bug
```
>>> series(2**n, n, oo, -1)
O(n, (n, oo))
```

Isn't it wrong? Of course 2^n is not O(n) as n->inf...

Discussion:

Patch:
diff --git a/sympy/core/expr.py b/sympy/core/expr.py
index c6be21344a..a29b829801 100644
--- a/sympy/core/expr.py
+++ b/sympy/core/expr.py
@@ -2967,6 +2967,11 @@ def series(self, x=None, x0=0, n=6, dir="+", logx=None, cdir=0):
         if len(dir) != 1 or dir not in '+-':
             raise ValueError("Dir must be '+' or '-'")
 
+        if n is not None:
+            n = int(n)
+            if n < 0:
+                raise ValueError("Number of terms should be nonnegative")
+
         x0 = sympify(x0)
         cdir = sympify(cdir)
         from sympy.functions.elementary.complexes import im, sign


Test patch:
diff --git a/sympy/series/tests/test_series.py b/sympy/series/tests/test_series.py
index 2adeef40f8..6ae7ed2b84 100644
--- a/sympy/series/tests/test_series.py
+++ b/sympy/series/tests/test_series.py
@@ -402,3 +402,7 @@ def test_issue_24266():
     #type3: f(y)**g(x)
     assert ((y)**(I*pi*(2*x+1))).series(x, 0, 2) == exp(I*pi*log(y)) + 2*I*pi*x*exp(I*pi*log(y))*log(y) + O(x**2)
     assert ((I*y)**(I*pi*(2*x+1))).series(x, 0, 2) == exp(I*pi*log(I*y)) + 2*I*pi*x*exp(I*pi*log(I*y))*log(I*y) + O(x**2)
+
+
+def test_issue_26856():
+    raises(ValueError, lambda: (2**x).series(x, oo, -1))