A154566 Smallest 10-digit number whose n-th power contains each digit (0-9) n times, or -1 if no such number exists.
1023456789, 3164252736, 4642110594, 5623720662, 6312942339, 6813614229, 7197035958, 7513755246, 7747685775, 7961085846, 8120306331, 8275283289, 8393900487, 8626922994, 8594070624, 8691229761, 8800389678, 8807854905, 9873773268, 8951993472, 9473643936, 9585032094
Offset: 1
Examples
For n=18, a(n)=8807854905. That means 8807854905^18 has all digits 0-9 each 18 times and 8807854905 is the smallest 10-digit number which has this property.
Links
- Zhining Yang, Smallest Ten Digit Powers
- Zhining Yang, Largest Ten Digit Powers
Programs
-
Python
def flag(p, n): for i in range(10): if not p.count(str(i)) == n: return False return True def a(n): for i in range(3*int(10**(10-1/n)/3), 10**10, 3): if flag(str(i**n), n): return i for i in range(1, 41): print(a(i), end=", ") # Zhining Yang, Oct 05 2022
-
VBA
Function Flag(ByVal s As String, ByVal num As Long) As Long Dim b&(9), t&, i& Flag = 1 If Len(s) <> 10 * num Then Flag = 0 Exit Function End If For i = 1 To Len(s) t = Val(Mid(s, i, 1)) b(t) = b(t) + 1 If b(t) > num Then Flag = 0 Exit Function End If Next End Function ' Function Mypower(ByVal num As Currency, ByVal power As Long) As String Dim b(), temp, i&, j& ReDim b(1 To 2 * power) ReDim s(1 To 2 * power) b(2 * power - 1) = Val(Left(num, 5)) b(2 * power) = Val(Right(num, 5)) For i = 2 To power temp = 0 For j = 2 * power To 1 Step -1 temp = b(j) * num + temp b(j) = Format(Val(Right(temp, 5)), "00000") temp = Int(temp / 10 ^ 5) Next Next Mypower = Join(b, "") End Function ' Function a(ByVal n As Long) Dim j As Currency, s As String, num& For j = 3 * Int(1 + 10 ^ (10 - 1 / n) / 3) To 9999999999# Step 3 DoEvents If Flag(Mypower(j, n), n) = 1 Then a = j Exit Function End If Next End Function ' Zhining Yang, Oct 11 2022
Extensions
Edited by N. J. A. Sloane, Jan 13 2009
Edited by Charles R Greathouse IV, Nov 01 2009
Further edits by M. F. Hasler, Oct 05 2012
a(19)-a(22) from Giovanni Resta, Jan 17 2020
Added escape clause to definition. - N. J. A. Sloane, Nov 22 2022
Comments