2017th Lucky Number

A Lucky Number is a positive integer whose digits, in base-10 notation, are only 4 or 7.

Find the number of occurrences of the digit 7 in base-10 notation of the 201 7 th 2017^\text{th} smallest Lucky Number .


The answer is 6.

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.

1 solution

Deeparaj Bhat
Jan 1, 2017

Consider the following (recursive) map f f from the set of all lucky numbers (represented as strings) to string of binary numbers :

f ( 4 x ) = 0 f ( x ) f ( 7 x ) = 1 f ( x ) f ( 4 ) = 0 f ( 7 ) = 1 f(4x) = \,'0'f(x) \\ f(7x) = \,'1'f(x) \\ f(4) =\, '0' \\ f(7) =\, '1'

For example, f ( 47 ) = 0 f ( 7 ) = 0 1 f(47) =\, '0'f(7) =\, '01' . Note that f f is both bijective and order preserving (assuming lexicographic ordering for strings).

Also, note that number of binary strings of length less than n n are r = 1 n 1 2 r = 2 n 2 \sum_{r = 1}^{n - 1} 2^r = 2^n - 2

So, if k k is the length of f ( 2017th smallest Lucky number ) f(\text{2017th smallest Lucky number}) , then 2 k 2 2017 and 2 k + 1 2 > 2017 k = 10 2^k - 2 \leq 2017 \text{ and } 2^{k + 1} - 2 > 2017 \implies k = 10

Hence, 2017th Lucky number = f 1 ( binary representation of { 2017 ( 2 10 2 ) 1 } ) = f 1 ( 111110010 0 ) = 7777744744 \text{ 2017th Lucky number } = f^{-1} (\text{ binary representation of } \{2017 - (2^{10} - 2) -1\}) = f^{-1} ('1111100100') = 7777744744

Facepalm-ed when I entered the number and not the number of 7's, sigh

Razzi Masroor - 4 years, 5 months ago

It's the same idea I had. Thanks!

Muhammad Rasel Parvej - 4 years, 5 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...