0 Replies - 1482 Views - Last Post: 10 May 2012 - 08:00 PM

#1 atraub   User is offline

  • Pythoneer
  • member icon

Reputation: 830
  • View blog
  • Posts: 2,251
  • Joined: 23-December 08

Digit Product Sequence Generator

Posted 10 May 2012 - 08:00 PM

Description: A generator to model the sequence explained here: http://facstaff.bloo.../sequences.html
__author__ = "atraub"
__date__= "5/10/2012"

def digitProductSequenceGenerator(seed=1):
    """given a seed, creates a digit Product Sequence Generator"""
    currentValue = int(seed)
    while True:
        yield currentValue
        product = 1
        for digit in str(currentValue):#multiply all non-0 digits together
            if digit != "0":
                product *= int(digit)
        currentValue += product#add product to current value to get next value



Is This A Good Question/Topic? 0
  • +

Page 1 of 1