A Very Special Number

Find the smallest positive integer n n such that the first 10 digits of n 3 \sqrt[3]{n} contain all the digits from 0 to 9 exactly once each.

Clarification: For example, the first 4 digits of 2 3 = 1.25992 \sqrt[3]{2} = 1.25992\ldots are 1, 2, 5, and 9.


The answer is 2017.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

3 solutions

Christopher Boo
Jan 4, 2017

The tricky part is to evaluate the decimals, but we can keep multiplying it by 10 until we have the first 10 digits. To check if all numbers are unique, throw everything into a set, which by definition doesn't contain duplicates, and the length should be 10.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
def very_special(x):
    y = pow(x, 1.0 / 3)
    z = str(int(y * pow(10, 10)))

    digits = []
    for i in range(10):
        digits.append(z[i])

    digits = set(digits)
    return len(digits) == 10

num = 1
while True:
    if very_special(num):
        print num
        break
    num += 1

Isn't that an amazing property of 2017?

Sharky Kesa - 4 years, 5 months ago

Log in to reply

Yes, it is! How did you come to notice this?

Agnishom Chattopadhyay - 4 years, 5 months ago

Log in to reply

Playing around with a calculator. :P :P

Then I did a similar, but longer brute force script on Python to find out some numbers which satisfied. Turned out 2017 was the first that did so, though 304 works if we were to look at 10 significant figures.

Sharky Kesa - 4 years, 5 months ago
Abdelhamid Saadi
Jan 7, 2017

A shorter solution in python, could be:

1
2
3
4
5
6
"A Very Special Number"

n = 1
while len(set( "{0}".format(n**(1/3)).replace('.','')[0:10])) != 10:
    n += 1
print(n)

Output

2017

Idk but your code is showing timeout error?! on online judge

Kunal Gupta - 4 years, 1 month ago

Log in to reply

Try it on https://ideone.com
Code in python 3.

Abdelhamid Saadi - 4 years, 1 month ago

No way to do this on paper?

Khushi Mehta - 4 years, 5 months ago

Log in to reply

This is a Computer Science problem, it should be solved using program only.

Pi Han Goh - 4 years, 5 months ago
Nicola Mignoni
Feb 21, 2018

Basically, I start with n = 2 n=2 and I evaluate n 3 \sqrt[3]{n} for each loop. Now I take each digit d i [ 0 , 1 , . . . , 9 ] d_i\in[0,1,...,9] , 1 i 10 1 \leq i \leq 10 and I put it in an empty array A A such that A d i = d i A_{d_i}=d_i . For example, if I'm looking at the 5 5 th digit of the root whose value is 6 6 ( d 5 = 6 d_5=6 ), I'll put it in A 6 A_6 . If d i = 0 d_i=0 , than A 10 = 0 A_{10}=0 . If I'm looking at a digit for the second time, its place in A A will be already occupied and than the loop stops and goes for n + 1 n+1 . The algorithm finds a solution when A = [ 1 , 2 , 3 , . . . , 0 ] A=[1,2,3,...,0] .

MATLAB code:

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...