# This program demonstrates a generator function. # Generator function for producing infinite sequences # of the Fibonacci numbers, which are defined as the sum # of the preceding two numbers. def fib(): a = 0 b = 1 while True: c = a + b a = b b = c yield c # Returns the number of unique digit values in the given integer. # For example, unique_digit_values(3141338) returns 4. def unique_digit_values(n): digits_seen = set() while n > 0: last_digit = n % 10 n = n // 10 digits_seen.add(last_digit) return len(digits_seen) def main(): # invoke the generator 12 times gen = fib() for i in range(1, 999): f = next(gen) print(i, "fib value is", f) if unique_digit_values(f) == 10: print("Found!", f) break # find Fib number that uses all 10 digit values main()