r""" Python module for OEIS sequence number A019463. Add 1, multiply by 1, add 2, multiply by 2, and so on. Examples of use. ----------------------------------------------------------------------- >>> from a019463 import * >>> print a019463_list(14) [1, 2, 2, 4, 8, 11, 33, 37, 148, 153, 765, 771, 4626, 4633] >>> print a019463_offset 0 >>> for x in a019463_list_pairs(6): ... print x ... (0, 1) (1, 2) (2, 2) (3, 4) (4, 8) (5, 11) >>> print a019463(5) 11 ----------------------------------------------------------------------- """ from itertools import islice, izip, count from a019460 import a019460_gen __all__ = ('a019463_offset', 'a019463_list', 'a019463_list_pairs', 'a019463', 'a019460_gen') __author__ = 'Nick Hobson ' a019463_offset = offset = 0 def a019463_list(n): """Returns a list of the first n >= 0 terms.""" if n < 0: raise ValueError, 'Input must be a non-negative integer' return list(islice(a019460_gen(1), n)) def a019463_list_pairs(n): """Returns a list of tuples (n, a(n)) of the first n >= 0 terms.""" if n < 0: raise ValueError, 'Input must be a non-negative integer' return list(izip(xrange(offset, n+offset), a019460_gen(1))) def a019463(n): """Returns the term with index n >= 0; offset 0.""" if n < offset: raise ValueError, 'Input must be an integer >= offset = ' + str(offset) return list(islice(a019460_gen(1), n-offset, n-offset+1)).pop()