Here is the solution with Python:
def last_digit(n1, n2): if n2 == 0: return 1 last_digits = [] step = 1 while True: number = pow(n1, step) step += 1 last_digit = int(str(number)[-1]) if last_digit in last_digits: break last_digits.append(last_digit) print(last_digits) last_digit_index = n2 % len(last_digits) - 1 return last_digits[last_digit_index]
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Here is the solution with Python: