A376003 Positive integers k such that each digit of k^2 is a factor of k.
1, 6, 12, 36, 54, 108, 156, 168, 192, 204, 288, 306, 408, 432, 486, 696, 804, 1104, 1146, 1188, 1488, 1512, 1632, 1764, 1806, 1932, 2232, 2904, 3114, 3408, 3456, 3528, 4014, 4104, 4392, 4596, 4608, 4704, 4788, 4872, 4932, 4944, 5208, 5304, 5868, 6012, 6696, 6792
Offset: 1
Examples
k = 12 is a term since k^2 = 144 has digits 1 and 4 and both are factors of k. k = 2 is not a term since k^2 = 4 has a digit 4 which is not a factor of k.
Programs
-
Maple
q:= n-> andmap(x-> x>0 and irem(n, x)=0, convert(n^2, base, 10)): select(q, [$1..10000])[]; # Alois P. Heinz, Sep 28 2024
-
PARI
isok(k) = my(d=Set(digits(k^2))); if(!vecmin(d), return(0)); for (i=1, #d, if (k % d[i], return(0))); return(1); \\ Michel Marcus, Sep 28 2024
-
Python
def is_valid_k(k): k_squared = k ** 2 for digit in str(k_squared): d = int(digit) if d == 0 or k % d != 0: return False return True def find_valid_k(max_k): valid_k = [] for k in range(1, max_k + 1): if is_valid_k(k): valid_k.append(k) return valid_k max_k = 10000 result = find_valid_k(max_k) print(result)
Comments