func super_d(d) {
var D = Str(d)*d
1..Inf -> lazy.grep {|n| Str(d * n**d).contains(D) }
}
for d in (2..8) {
say ("#{d}: ", super_d(d).first(10))
}
Output:
2: [19, 31, 69, 81, 105, 106, 107, 119, 127, 131]
3: [261, 462, 471, 481, 558, 753, 1036, 1046, 1471, 1645]
4: [1168, 4972, 7423, 7752, 8431, 10267, 11317, 11487, 11549, 11680]
5: [4602, 5517, 7539, 12955, 14555, 20137, 20379, 26629, 32767, 35689]
6: [27257, 272570, 302693, 323576, 364509, 502785, 513675, 537771, 676657, 678146]
7: [140997, 490996, 1184321, 1259609, 1409970, 1783166, 1886654, 1977538, 2457756, 2714763]
8: [185423, 641519, 1551728, 1854230, 6415190, 12043464, 12147605, 15517280, 16561735, 18542300]