Python
def auto_morphic(num): return str(num*num)[-1] == str(num)[-1]
More tests:
print(auto_morphic(13), False) print(auto_morphic(25), True) print(auto_morphic(6), True) print(auto_morphic(625), True) print(auto_morphic(225), True) print(auto_morphic(1), True) print(auto_morphic(2), False) print(auto_morphic(3), False) print(auto_morphic(4), False) print(auto_morphic(5), True) print(auto_morphic(6), True) print(auto_morphic(7), False) print(auto_morphic(8), False) print(auto_morphic(9), False) print(auto_morphic(10), True) print(auto_morphic(11), True) print(auto_morphic(12), False)
11 should be false?
11 * 11 is 121, which ends in 1 hence return True.
oops - i interpreted the problem incorrectly as only the oneβs digits needing to match.
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.
Python
More tests:
11 should be false?
11 * 11 is 121, which ends in 1 hence return True.
oops - i interpreted the problem incorrectly as only the oneβs digits needing to match.