Those are some nifty numbers

For each positive integer n n , let s ( n ) s(n) denote the sum of the digits of n n . We call a number nifty if it can be expressed as n s ( n ) n-s(n) for some positive integer n n .

How many positive integers less than 10 000 are nifty?


The answer is 1000.

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.

2 solutions

Mark Hennings
Feb 18, 2017

With the exception of 9999 = 10000 s ( 10000 ) 9999 = 10000 - s(10000) , any positive integer m m which is a nifty number can be written as n s ( n ) n - s(n) where n n is at most a 4 4 -digit number. If n = a b c d n = \overline{abcd} is an at most 4 4 -digit number, then n s ( n ) = 999 a + 99 b + 9 c = 9 ( 111 a + 11 b + c ) n-s(n) = 999a + 99b + 9c = 9(111a + 11b+c) . The value of d d does not matter, so we might as well choose d = 1 d=1 , so that n n is always a positive integer, for any values of 0 a , b , c 9 0 \le a,b,c \le 9 .

Now the map ( a , b , c ) 111 a + 11 b + c a , b , c = 0 , 1 , 2 , 9 (a,b,c) \mapsto 111a + 11b + c \hspace{2cm} a,b,c \,=\, 0,1,2, \ldots 9 is injective, and hence there are 1 0 3 = 1000 10^3 = 1000 numbers of the form 999 a + 99 b + 9 c = n s ( n ) 999a + 99b + 9c = n-s(n) for a positive integer n < 10000 n < 10000 . We need to exclude the case a = b = c = 0 a=b=c=0 , since this gives the nifty number 0 0 , which is not positive. On the other hand, we need to include the nifty number 9999 9999 in our count. Thus there are 1000 \boxed{1000} nifty positive integers less than 10000 10000 .

Nice solution. Do you think you could help us with finding a rule for multiples of 9 which cannot be written in this form?


EDIT: Your solution gives a method of doing so! Great!

Sharky Kesa - 4 years, 3 months ago

Log in to reply

Try 111 a + 11 b + c = 1 1 2 a + 11 ( b a ) + ( c + a ) 111a + 11b + c = 11^2a + 11(b-a) + (c+a) Counting in base 11 11 , the numbers you cannot get are basically those with a 10 a\equiv10 , b a 1 b\equiv a-1 or c a 1 c\equiv-a-1 modulo 11 11 .

Mark Hennings - 4 years, 3 months ago

Log in to reply

Can we generalise this to a 1 + 11 a 2 + 111 a 3 + + 111...111 a n a_1 + 11a_2 + 111a_3 + \ldots + 111...111 a_n ?

Sharky Kesa - 4 years, 3 months ago

Let the no be 10x+y Then a nighty must be tight Means a nifty must be divisible by 9 So nifty =9990=(n-1)*10 N=1000 So there are 1000 tight nighties or nifties

Meera Somani - 4 years, 3 months ago
Sharky Kesa
Feb 10, 2017

Let f ( n ) = n s ( n ) f(n)=n-s(n) . Observe that

f ( 10 m ) = f ( 10 m + 1 ) = f ( 10 m + 2 ) = f ( 10 m + 3 ) = = f ( 10 m + 9 ) f(10m)=f(10m+1) = f(10m+2) = f(10m+3)=\ldots =f(10m+9)

for all positive integers m m . From this, we get all nifty numbers belong in the sequence f ( 10 ) , f ( 20 ) , f ( 30 ) , f(10), f(20), f(30), \ldots .

Also note f ( 10 m ) < f ( 10 m + 10 ) f(10m) < f(10m+10) for all positive integers m m . This statement is equivalent to

10 m s ( 10 m ) < 10 m + 10 s ( 10 m + 10 ) s ( m + 1 ) s ( m ) < 10 10m - s(10m) < 10m+10 - s(10m+10) \iff s(m+1)-s(m) < 10

where we used the fact s ( 10 m ) = s ( m ) s(10m)=s(m) . The inequality sign s ( m + 1 ) s ( m ) < 10 s(m+1)-s(m) < 10 is trivially true for m ≢ 9 ( m o d 10 ) m \not \equiv 9 \pmod{10} , since m + 1 m+1 and m m only differ in their last digit. To see that s ( m + 1 ) s ( m ) < 10 s(m+1) - s(m) < 10 if m 9 ( m o d 10 ) m \equiv 9 \pmod{10} , suppose m m ends in k k 9s. Then the last k k digits of m + 1 m+1 are 0's, while the preceding digit has increased by 1. Thus, s ( m + 1 ) s ( m ) = 1 9 k < 10 s(m+1) - s(m) = 1-9k < 10 .

Since f ( 10000 ) = 9999 f(10000)=9999 and f ( 10010 ) = 10008 f(10010)=10008 , it follows that the nifty positive integers less than 10000 are precisely the following.

f ( 10 ) < f ( 20 ) < f ( 30 ) < < f ( 10000 ) f(10) < f(20) < f(30) < \ldots < f(10000)

Therefore, there are 1000 \boxed{1000} nifty positive integers less than 10000.

Ah interesting. Even though "multiple of 9" is a necessary condition, it is not a sufficient condition. For example, 90 isn't a nifty number.

I wonder if we can easily classify all multiples of 9 that are not nifty.

Calvin Lin Staff - 4 years, 4 months ago

Log in to reply

Some multiples of 9 that aren't nifty (from observation):

90, 189, 288, 387, 486, 585, 684, 783, 882, 981,

990, 1089, 1188, 1287, 1386, 1485, 1584, 1683, 1782, 1881,

1980

1989, 2088, 2187, 2286, 2385, 2484, 2583, 2682, 2781

There seems to be addition of 99 to get to the next number, but this sequence breaks down. Seems interesting. I'll see what I can do here.

Sharky Kesa - 4 years, 4 months ago

Log in to reply

OK, I got all non-nifty multiples of 9 under 10000:

90, 189, 288, 387, 486, 585, 684, 783, 882, 981,

990, 1089, 1188, 1287, 1386, 1485, 1584, 1683, 1782, 1881,

1980, 1989, 2088, 2187, 2286, 2385, 2484, 2583, 2682, 2781,

2880, 2979, 2988, 3087, 3186, 3285, 3384, 3483, 3582, 3681,

3780, 3879, 3978, 3987, 4086, 4185, 4284, 4383, 4482, 4581,

4680, 4779, 4878, 4977, 4986, 5085, 5184, 5283, 5382, 5481,

5580, 5679, 5778, 5877, 5976, 5985, 6084, 6183, 6282, 6381,

6480, 6579, 6678, 6777, 6876, 6975, 6984, 7083, 7182, 7281,

7380, 7479, 7578, 7677, 7776, 7875, 7974, 7983, 8082, 8181,

8280, 8379, 8478, 8577, 8676, 8775, 8874, 8973, 8982, 9081,

9180, 9279, 9378, 9477, 9576, 9675, 9774, 9873, 9972, 9981,

9990


This isn't an OEIS sequence either.

Sharky Kesa - 4 years, 4 months ago

Log in to reply

@Sharky Kesa You should submit it as a sequence on OEIS!

I don't quite see a pattern other than it's explicit description. Interesting, will have a think about this.

Calvin Lin Staff - 4 years, 3 months ago

Log in to reply

@Calvin Lin A282473 has been submitted to OEIS pending review. :)

Sharky Kesa - 4 years, 3 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...