I am thinking of a 6-digit number. The sum of the digits is 43.
And only two of the following three statements about the number are true:
(1) it's a square number,
(2) it's a cube number, and
(3) the number is under 500000.
Find the number.
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.
Congrats on being able to code in Python!
Here 's a C++ solution. Adding it here for the sake of variety.
Did you like the problem ?
Log in to reply
Yes. I do.
Log in to reply
Then like and re share it for others.
Log in to reply
@Rama Devi – Please up vote my solution if you like it.
We can deduce that the answer is 499849 by the following steps.
Max sum of numbers is 4+9+9+9+9+9, which equals 49, from this You can deduce that the number is fairly close to the 499999.
It may be a square number. So the square is below square of max sqrt(499999)~707.10607. By trying squares below 707.1.... You will find the right answer that is 707^2.
Only statements 1 and 3 are true because there exists no cube number,whose digits' sum is 43.
I got this wrong, because I failed to read the part that says "only two of the following three statements about this number are true".
But here's some Python anyway:
Python 3.4:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
Log in to reply
So , you got trapped.Then why don't you up vote my solution.
Your solution is incomplete. You didn't show that there is no other number with only satisfies 2 of the 3 statements.
Can you come up with a one line argument why condition 2 cannot be true if the sum of the digits is 43?
Log in to reply
I did not mean that 2 cannot be true.
Log in to reply
I know you did not mean that, nor did you say that. That is why your solution is incomplete, because you didn't show that we could have 1 and 2 being satisfied.
I am saying that
There is no perfect cube whose digit sum is 43.
Log in to reply
@Calvin Lin – Exactly.That is what I mean.
Any way , thanks, I will edit my solution right now.
Log in to reply
@Rama Devi – Note that you should still explain why "there is no cube number whose digit sum is 43". That is not immediately obvious.
Log in to reply
@Calvin Lin – How it that possible?
Log in to reply
@Rama Devi – Show that the "cubic residues mod 9" are only 0, 1, 8.
We know that n 3 ≡ digit sum of n 3 ≡ 4 3 ( m o d 9 ) .
Hence, there is no solution.
Since there aren't many six-digit squares and cubes it's reasonably inexpensive to use a lookup list for them.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
Problem Loading...
Note Loading...
Set Loading...
Yay! I can finally code in python!