$ cat test.c
#include <stdint.h>
#include <stdio.h>
static inline void test(uint64_t x)
{
const uint64_t xxx = x * x * x;
unsigned int mask = 0;
uint64_t tmp = xxx;
while (tmp != 0) {
const unsigned int digit_mask = 1u << (tmp % 10);
if (digit_mask & mask) {
fprintf(stderr, "! %3ld %10ld -> %1ld\n", x, xxx, tmp % 10);
return;
}
mask |= digit_mask;
tmp /= 10;
}
printf("%3ld %10ld\n", x, xxx);
}
int main()
{
for (uint64_t x=1000; x<=2155; ++x)
test(x);
}
$ gcc -std=gnu99 test.c -o test
$ ./test 2>/dev/null
$ ./test
! 1000 1000000000 -> 0
! 1001 1003003001 -> 0
! 1002 1006012008 -> 0
! 1003 1009027027 -> 7
! 1004 1012048064 -> 4
! 1005 1015075125 -> 5
! 1006 1018108216 -> 1
! 1007 1021147343 -> 3
..................................
! 2146 9883008136 -> 0
! 2147 9896830523 -> 3
! 2148 9910665792 -> 6
! 2149 9924513949 -> 9
! 2150 9938375000 -> 0
! 2151 9952248951 -> 2
! 2152 9966135808 -> 8
! 2153 9980035577 -> 7
! 2154 9993948264 -> 4
! 2155 10007873875 -> 7