# HG changeset patch
# User Nathann Cohen
# Date 1287930693 7200
# Node ID 3832e843cc5df6e99984bfe57c29a8b91f081043
# Parent e894562da4d58ab43dcb43ba007c87453252ca9d
trac 10025  some docstring/doctests problems in sloane.A109814
diff r e894562da4d5 r 3832e843cc5d sage/combinat/sloane_functions.py
 a/sage/combinat/sloane_functions.py Tue Sep 28 11:58:43 2010 +0200
+++ b/sage/combinat/sloane_functions.py Sun Oct 24 16:31:33 2010 +0200
@@ 50,8 +50,7 @@
We agree with the online database::
sage: for t in sloane.trait_names(): # long time optional, requires internet
 ... print t
 ... online_list = sloane_sequence(ZZ(t[1:].lstrip('0')))[2]
+ ... online_list = sloane_sequence(ZZ(t[1:].lstrip('0')), verbose = False)[2]
... L = max(2, len(online_list) // 2)
... sage_list = sloane.__getattribute__(t).list(L)
... if online_list[:L] != sage_list:
@@ 8993,33 +8992,57 @@
return perm_mh(n, 4)
class A109814(SloaneSequence):
 def __init__(self):
 r"""
 The `n`th term of the sequence `a(n)` is the
 largest `k` such that `n` can be written as sum of
 `k` consecutive integers.

 `n` is the sum of at most `a(n)` consecutive
 positive integers. Suppose `n` is to be written as sum of
 `k` consecutive integers starting with `m`, then
 `2n = k(2m + k  1)`. Only one of the factors is odd. For
 each odd divisor `d` of `n` there is a unique
 corresponding `k = min(d,2n/d)`. `a(n)` is the
 largest among those `k` . See:
 http://www.jaapspies.nl/mathfiles/problem20052C.pdf

 INPUT:


  ``n``  non negative integer


 OUTPUT:


  ``integer``  function value


+ r"""
+ The `n` th term of the sequence `a(n)` is the
+ largest `k` such that `n` can be written as sum of
+ `k` consecutive integers.
+
+ By definition, `n` is the sum of at most `a(n)` consecutive
+ positive integers. Suppose `n` is to be written as sum of `k`
+ consecutive integers starting with `m`, then `2n = k(2m + k 
+ 1)`. Only one of the factors is odd. For each odd divisor `d`
+ of `n` there is a unique corresponding `k =
+ min(d,2n/d)`. `a(n)` can be alternatively defined as the
+ largest among those `k` .
+
+ .. SEEALSO::
+
+ * `Wikipedia article on polite numbers
+ `_.
+
+ * `An exercise sheet (with answers) about sums of
+ consecutive integers
+ `_.
+
+ INPUT:
+
+  ``n``  non negative integer
+
+
+ OUTPUT:
+
+  ``integer``  function value
+
+ EXAMPLES::
+
+ sage: a = sloane.A109814; a
+ a(n) is the largest k such that n can be written as sum of k consecutive positive integers.
+ sage: a(0)
+ Traceback (most recent call last):
+ ...
+ ValueError: input n (=0) must be a positive integer
+ sage: a(2)
+ 1
+ sage: a.list(9)
+ [1, 1, 2, 1, 2, 3, 2, 1, 3]
+
+ AUTHORS:
+
+  Jaap Spies (20070113)
+ """
+
+ def __init__(self):
+ r"""
EXAMPLES::
sage: a = sloane.A109814; a
@@ 9032,10 +9055,6 @@
1
sage: a.list(9)
[1, 1, 2, 1, 2, 3, 2, 1, 3]

 AUTHORS:

  Jaap Spies (20070113)
"""
SloaneSequence.__init__(self, offset=1)
diff r e894562da4d5 r 3832e843cc5d sage/databases/sloane.py
 a/sage/databases/sloane.py Tue Sep 28 11:58:43 2010 +0200
+++ b/sage/databases/sloane.py Sun Oct 24 16:31:33 2010 +0200
@@ 458,11 +458,21 @@
list = signed
return [seqnum, description, [ZZ(n) for n in list]]
def sloane_sequence(number):
+def sloane_sequence(number, verbose = True):
"""
Returns a list with the number, name, and values for the sequence
``number`` in Sloane's online database of integer
sequences.
+
+ INPUT:
+
+  ``number`` (integer) corresponding to the sequence.
+
+  ``verbose``  (boolean) print a string to let the
+ user know that it is working and not hanging.
+
+ Set to ``True`` by default.
+
EXAMPLES::
@@ 489,7 +499,7 @@
number = str(ZZ(number))
except TypeError:
raise TypeError, "input must be an integer or string that specifies the id of the Sloane sequence to download"
 results = sloane_find('id:A%s'%number)
+ results = sloane_find('id:A%s'%number, verbose = verbose)
if len(results) == 0:
raise ValueError, "sequence '%s' not found"%number
return results[0]