r""" Python module for OEIS sequence number A082448. Add 1, multiply by 1, add 2, multiply by 2, and so on. Examples of use. ----------------------------------------------------------------------- >>> from a082448 import * >>> print a082448_list(14) [4, 5, 5, 7, 14, 17, 51, 55, 220, 225, 1125, 1131, 6786, 6793] >>> print a082448_offset 0 >>> for x in a082448_list_pairs(6): ... print x ... (0, 4) (1, 5) (2, 5) (3, 7) (4, 14) (5, 17) >>> print a082448(5) 17 ----------------------------------------------------------------------- """ from itertools import islice, izip, count from a019460 import a019460_gen __all__ = ('a082448_offset', 'a082448_list', 'a082448_list_pairs', 'a082448', 'a019460_gen') __author__ = 'Nick Hobson ' a082448_offset = offset = 0 def a082448_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(4), n)) def a082448_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(4))) def a082448(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(4), n-offset, n-offset+1)).pop()