20
2
An Automorphic number is a number which is a suffix of its square in base 10. This is sequence A003226 in the OEIS.
Your Task:
Write a program or function to determine whether an input is an Automorphic number.
Input:
An integer between 0 and 10^12 (inclusive), that may or may not be an Automorphic number.
Output:
A truthy/falsy value indicating whether or not the input is an Automorphic number.
Examples:
0 -> truthy
1 -> truthy
2 -> falsy
9376 -> truthy
8212890625 -> truthy
Scoring:
This is code-golf, lowest score in bytes wins.
9Btw the limit of 1e12 means submissions will need to handle numbers up to 1e24, which is an 80-bit number. If handling numbers that large is a hard requirement, many of the exiting answers are invalid. – Dennis – 2017-06-24T19:59:49.373
Need we handle numbers that would lead to precision issues in our chosen language? – Shaggy – 2017-06-24T21:50:23.120
Provided that you don't abuse the standard loophole about that, then that would be fine. – Gryphon – 2017-06-24T22:49:35.207
Specifically, this loophole
– Gryphon – 2017-06-24T22:53:38.727It's been a loooong day and I am very, very tired but your comments read to me as validating my JS solution. Could you confirm that? (No issue deleting if not) – Shaggy – 2017-06-24T23:40:03.053
Consider that confirmed. 10^9 (which is what I'm pretty sure your program stops working after) is good enough. I just don't want things that only work on numbers up to, say 1,000. – Gryphon – 2017-06-24T23:42:35.347