cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A154566 Smallest 10-digit number whose n-th power contains each digit (0-9) n times, or -1 if no such number exists.

Original entry on oeis.org

1023456789, 3164252736, 4642110594, 5623720662, 6312942339, 6813614229, 7197035958, 7513755246, 7747685775, 7961085846, 8120306331, 8275283289, 8393900487, 8626922994, 8594070624, 8691229761, 8800389678, 8807854905, 9873773268, 8951993472, 9473643936, 9585032094
Offset: 1

Views

Author

Zhining Yang, Jan 12 2009, Jan 13 2009

Keywords

Comments

A number with 10*n digits could contain all ten digits(0-9) n times. The probability of this is (10n)!/((n!)^10 * 10^((10*n)-10^(10*n-1)). There are 10^10-10^(10-1/n)) numbers which are n-th powers of some 10-digit numbers. So there are about (10n)!*(10^10-10^(10-1/n)))/((n!)^10 * 10^((10*n)-10^(10*n-1)) numbers which satisfy the requirements.
Fortunately, I found a larger number than those shown here, for n=26, a(n)=9160395852. Since (10n)!*(10^10-10^(10-1/n))/((n!)^10 * 10^((10*n)-10^(10*n-1)) = 0.31691419..., this is a lucky event!
The sequence is -1 beyond a certain point because when n > 23025850928 we have 9999999999^n < 10^(10*n-1), i.e., it is impossible to obtain a power with 10*n digits. From a(23) to a(600) the only terms which are not -1 are a(24)=9793730157, a(26)=9160395852, a(35)=9959167017, and a(38)=9501874278. - Giovanni Resta, Jan 17 2020

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.
		

Crossrefs

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