Looking at consecutive powers of `2`, starting with `2^1`:

`2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, ...`

Note that out of all the digits `0-9`, the last one ever to appear is `7`. It only shows up for the first time in the number `32768 (= 2^15)`.

So let us define LAST DIGIT TO APPEAR as the last digit to be written down when writing down all the powers of `n`, starting with `n^1`.


## Your task

You'll be given a positive integer ```1 =< n <= 10000```, and must return the last digit to appear, as an integer.

If for any reason there are digits which never appear in the sequence of powers, return `None`/`nil`.

Please note: The Last digit to appear can be in the same number as the penultimate one. For example for `n = 8`, the last digit to appear is `7`, although `3` appears slightly before it, in the same number:
`8, 64, 512, 4096, 32768, ...`

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def LDTA(n):
	

Solutions:
digits = lambda x: set(str(x))

def LDTA(n):
	if digits(n) == digits(n * n):
		return None
	seen = []
	x = n
	while len(seen) < 10:
		for d in str(x):
			if d not in seen:
				seen.append(d)
		x *= n
	return int(seen[-1])


def LDTA(n):
	(x, s) = (n, set(str(n)))
	for _ in range(30):
		x *= n
		for d in str(x):
			s.add(d)
			if len(s) == 10:
				return int(d)


import math

def LDTA(n):
	if math.log10(n) == int(math.log10(n)):
		return None
	d = {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0}
	c = n
	while 1:
		for i in str(c):
			d[int(i)] = 1
			if sum(d.values()) == 10:
				return int(i)
		c *= n
	return -1


import math

def LDTA(n):
	if n == 1 or math.log10(n) % 1 == 0:
		return None
	else:
		power = 1
		digits = [d for d in range(0, 10)]
		while digits:
			number = [int(x) for x in str(n ** power)]
			for x in number:
				if x in digits:
					last_one = x
					digits.remove(x)
			power += 1
		return last_one


def LDTA(n):
	digits = []
	num = 1
	pow = 1
	while num < n ** pow and pow < 20:
		num *= n
		pow += 1
		if len(digits) == 10:
			return digits[-1]
		else:
			for d in str(num):
				if int(d) not in digits:
					digits.append(int(d))
	return None


def LDTA(n):
	if set(str(n)) == set(str(n ** 2)):
		return
	(res, i) = ([], 0)
	while True:
		i += 1
		for digit in str(n ** i):
			if digit not in res:
				res.append(digit)
			if len(res) >= 10:
				return int(res[-1])


def LDTA(n):
	remaining = set(range(10))
	for i in range(1, 100):
		for s in str(n ** i):
			t = int(s)
			remaining.discard(t)
			if not remaining:
				return t


def LDTA(n):
	if n in (1, 10, 100, 1000, 10000):
		return None
	digits = set('0123456789')
	k = 1
	while True:
		p = str(n ** k)
		for digit in p:
			digits -= {digit}
			if len(digits) == 1:
				return int(digits.pop())
		k += 1


from itertools import islice

def iter_powers(n):
	x = n
	while True:
		yield from map(int, str(x))
		x *= n

def LDTA(n):
	appear = set(range(10))
	for x in islice(iter_powers(n), 1000):
		appear.discard(x)
		if len(appear) == 1:
			return appear.pop()


def is_enough(lst):
	return len(lst) >= 10

def LDTA(n):
	res = []
	for i in range(1, 20):
		c = str(n ** i)
		for digit in c:
			if digit not in res:
				res.append(digit)
			if is_enough(res):
				break
		if is_enough(res):
			break
	if is_enough(res):
		return int(res[-1])
	return