Spooky Numbers (Late Halloween Special)

A positive integer is called spooky if at least one of the numbers 13 or 31 occurs in at least one pair of consecutive digits in the integer. For example, the integers 13, 831, and 73138 are all spooky. How many spooky integers less than 1 0 4 10^4 are there?


The answer is 558.

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

Alex Segesta
Nov 2, 2017

Let us count the complement. Let a n a_n be the number of non-spooky numbers that end in 1 1 or 3 3 . Let b n b_n be the number of non-spooky numbers that do not end in 1 1 or 3 3 . Then we have the following recurrences:

a n + 1 = a n + 2 b n a_{n+1} = a_n+2b_n

b n + 1 = 8 ( a n + b n ) b_{n+1} = 8(a_n +b_n )

Since a 1 = 2 a_1 = 2 and b 1 = 8 b_1=8 , we can obtain that a 4 = 1746 a_4=1746 and b 4 = 7696 b_4=7696 . Thus, our desired answer is 1 0 4 ( 1746 + 7696 ) = 558 10^4-(1746+7696) = 558 .

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...