What is the smallest number that, when multiplied by 4, is simply the original number with the rightmost digit moved to the front of the number?
As an explicit example, if we replace the number 4 with 5 above, then we have 5 × 1 4 2 8 5 7 = 7 1 4 2 8 5 .
(Note that here I multiplied by 5, while the question asks for a number that works when multiplied by 4.)
Note: Don't consider numbers with leading zeroes.
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.
Great solution. At the start, you could simplify it by saying N = 1 0 k a + b , which makes seeing the 39b more obvious.
If number of digits of N is n + 1 you can write 4 ( 1 0 A + B ) = 1 0 n B + A 3 9 A = ( 1 0 n − 4 ) B where B is the rightmost digit of N and A is a n -digit number. It looks simpler this way. :)
#include<conio.h>
#include<math.h>
unsigned long int newnum (unsigned long int a)
{
unsigned long int lim=0,num2=0,m,digit,count=0;
m=a;
while(a>0)
{
lim+=1;
a=a/10;
}
a=m;
while(count<lim)
{
digit=a%10;
if(count==0)
num2+=digit*pow(10,lim-1);
else
num2+=digit*pow(10,count-1);
a=a/10;
count+=1;
}
a=m;
return num2;
}
void main()
{
clrscr();
unsigned long int a=1,x,y;
while(a<200000)
{
y=a%10;
x=newnum(a);
if(x==4*a&&y!=0)
{
cout << a;
break;
}
a=a+1;
}
getch();
}
I don't know why latex is acting up. This is the first time I'm posting a programming solution. And I'm not sure it's fair to do so here. Would really appreciate if a mod could do the needful here. There's a # in the beginning which somehow doesn't show up before people start pointing out.
Program runs in 10 secs to give the answer as 1 0 2 5 6 4
Problem Loading...
Note Loading...
Set Loading...
Let N = a 1 a 2 a 3 ⋯ a n be the number we are trying to find. We can write the condition in the problem as
4 a 1 a 2 a 3 ⋯ a n = a n a 1 a 2 ⋯ a n − 1 .
Let A = a 1 a 2 a 3 ⋯ a n − 1 and B = a n . We have
4 ( 1 0 A + B ) 4 0 A + 4 B 3 9 A 3 9 ( a 1 × 1 0 n − 2 + ⋯ + a n − 1 ) = 1 0 n − 1 B + A = A + 1 0 n − 1 B = B ( 1 0 n − 1 − 4 ) = a n ( 1 0 n − 1 − 4 ) .
Now, since a n and 1 0 n − 1 − 4 are both integers, we must have that a n ( 1 0 n − 1 − 4 ) divides 3 9 . This is equivalent to saying that a n ( 1 0 n − 1 − 4 ) is divisible by both 3 and 1 3 . We know that
1 0 n − 1 − 4 ≡ 1 n − 1 − 1 ≡ 0 ( m o d 3 ) ,
so either 1 3 ∣ a n or 1 3 ∣ 1 0 n − 1 − 4 . If 1 3 ∣ a n , then a n ≥ 1 3 , which cannot happen since a n is a digit. Thus, we must have 1 3 ∣ 1 0 n − 1 − 4 , or 1 0 n − 1 ≡ 4 ( m o d 1 3 ) . Checking powers of 1 0 mod 1 3 , we find that 1 0 5 + 6 k ≡ 4 ( m o d 1 3 ) , for all nonnegative integers k . We want the smallest value of n , so we must have n − 1 = 5 , or n = 6 .
Now that we know the value of n , we can plug it into our original equation and divide both sides by 3 9 :
3 9 ( a 1 × 1 0 4 + ⋯ + a 5 ) 3 9 ( a 1 × 1 0 4 ⋯ + a 5 ) a 1 × 1 0 4 + a 2 × 1 0 3 + a 3 + 1 0 2 + a 4 × 1 0 + a 5 = a 6 ( 1 0 5 − 4 ) = 9 9 9 9 6 a 6 = 2 5 6 4 a 6 .
The left hand side is a five digit number, so we find the smallest value of a 6 such that 2 5 6 4 a 6 is a five digit number, which will give the smallest such five digit number. This yields a 6 = 4 , and a 1 a 2 a 3 a 4 a 5 = 2 5 6 4 × 4 = 1 0 2 5 6 . Thus, N = a 1 a 2 a 3 a 4 a 5 a 6 = 1 0 2 5 6 4 .
We can check easily that 1 0 2 5 6 4 × 4 = 4 1 0 2 5 6 , as desired.