Forum menu
I am thinking of a nine-digit decimal natural number. It contains all 9 numerals 1, 2, 3, 4, 5, 6, 7, 8, 9.
For each n = 1, ..., 9 the first n digits read as an n-digit decimal natural number are divisible by n. What is my number?
Are there aeroplanes on conveyors?
OK, so the first digit is one and the next digit is even, and the next digit odd, etc...
But now I've lost interest.
Feel free to stand on my shoulders.
76.2?
I have another cryptic puzzle for you lot...
What colour pants am I wearing?
For bonus points...
Why did I put them on inside out this morning?
TSY - I left your lime green thong out for you so I assume you're wearing that?
You're wearing it inside out to even the stains out?
42.
That's the answer to both questions, and any other you could possibly ask.
RealMan
5318008
TSY
a) Beige
b) Reduced washing
Hmm, but yet cared enough to post that. Now that is a [i]real[/i] puzzle!
Hmm, but yet [s]cared[/s]bored enough to post that. Now that is a real puzzle!
fixed that for you.
OK, so the first digit is one
I thought that initially but I don't thing it has to be.
e.g. digit (n=) 1 with a value of 2 is divisible by (n=) 1
2nd digit is 2, 5th is 5.
4th, 6th, 8th are even.
EDIT - not sure 2nd is 2 now.
I'd agree that the 5th is 5.
And that also any combination of the numbers will be divisible by 9, so you don't have to worry about that. (Not sure if that will help at all.)
That's about all I've really got at the moment..
71077345
FAIL ๐
189456327 ---ooops
I can see how I'd find a solution, but it is too painful to do by hand so I'd write code ๐
Seems to me you have to list the possible numbers for each position by looking at what the multiples of that position end with (e.g. for position 4: multiples of 4 end with 0,2,4,6,8 and the question says zero is not allowed)
Doing that gives:
[code]
1 2 3 4 5 6 7 8 9
----------------------
1 . 1 . . . 1 . 1
2 2 2 2 . 2 2 2 2
3 . 3 . . . 3 . 3
4 4 4 4 . 4 4 4 4
5 . 5 . 5 . 5 . 5
6 6 6 6 . 6 6 6 6
7 . 7 . . . 7 . 7
8 8 8 8 . 8 8 8 8
9 . 9 . . . 9 . 9
[/code]
Then you just... Erm...
CM that's not right...
GrahamS ๐
189456327
Erm 1894 is not divisible by 4. ๐
Aah then we do some elimination. The only possible number at position 5 is 5 and the 4 even positions needs the 4 even numbers so they can't be under odd.
[code]
1 2 3 4 5 6 7 8 9
----------------------
1 . 1 . . . 1 . 1
. 2 . 2 . 2 . 2 .
3 . 3 . . . 3 . 3
. 4 . 4 . 4 . 4 .
. . . . 5 . . . .
. 6 . 6 . 6 . 6 .
7 . 7 . . . 7 . 7
. 8 . 8 . 8 . 8 .
9 . 9 . . . 9 . 9
[/code]
Then erm....
987654321 - then, i'm gonna start moving them around!!!
147258369
My pants are black with a pink waistband.
I was just really tired when getting dressed this morning.
381654729
147258369
But 14725836 does not divide by 8
By jove, i think he's got it (guattang, that is)
indeed
was there a method?
381654729
Winner! But where is your working...? ๐
I got a far as reading off the remaining valid combinations of 3 digits from my grid and eliminating the ones not divisible by 3, leaving:
123, 129, 147, 183, 189, 321, 327, 381, 387
723, 729, 747, 783, 789, 921, 927, 981, 987
My next step would have been to try each of those with the possibles from the 4 column, but then I decided there must be an easier way ๐
Squadron Leader Brian Trubshaw.
guattang, how did you get it?
I did it a in a simple loop (in a bash script if you're interested ...). I took the brute force approach, but runtime was only about 10 seconds.
So no mathematical genius, just code?
TBH, I'm struggling to see how it would be done anyway else. Cheers though.
Afraid not. No genius here ... wether it be mathematical or otherwise ...
Lets see that code ๐
Would something like this help:
[url= http://math.about.com/library/bldivide.htm ]http://math.about.com/library/bldivide.htm[/url]
EDIT - so looking at options from GrahamS's table, 4th digit can't be 4 or 8.
It's a bit Sudoku ish.
Hmmm ... not very elegant I'm afraid!!
#!/bin/bash
function test
{
num1=$1
num2=$2
((r=($num1/$num2)*$num2))
if [[ $r -eq $num1 ]]; then
echo 0
else
echo 1
fi
}
for n1 in printf "1\n2\n\n3\n4\n6\n7\n8\n9"
do
for n2 in printf "2\n4\n6\n8" | grep -v "$n1"
do
for n3 in printf "1\n2\n\n3\n4\n6\n7\n8\n9" | grep -v -E "$n1|$n2"
do
for n4 in printf "2\n4\n6\n8" | grep -v -E "$n1|$n2|$n3"
do
for n5 in printf "5"
do
for n6 in printf "2\n4\n6\n8" | grep -v -E "$n1|$n2|$n3|$n4|$n5"
do
for n7 in printf "1\n2\n\n3\n4\n6\n7\n8\n9" | grep -v -E "$n1|$n2|$n3|$n4|$n5|$n6"
do
for n8 in printf "2\n4\n6\n8" | grep -v -E "$n1|$n2|$n3|$n4|$n5|$n6|$n7"
do
for n9 in printf "1\n2\n\n3\n4\n6\n7\n8\n9" | grep -v -E "$n1|$n2|$n3|$n4|$n5|$n6|$n7|$n8"
do
if [[ test $n1 1 = "0" ]]; then
if [[ test ${n1}${n2} 2 = "0" ]]; then
if [[ test ${n1}${n2}${n3} 3 = "0" ]]; then
if [[ test ${n1}${n2}${n3}${n4} 4 = "0" ]]; then
if [[ test ${n1}${n2}${n3}${n4}${n5} 5 = "0" ]]; then
if [[ test ${n1}${n2}${n3}${n4}${n5}${n6} 6 = "0" ]]; then
if [[ test ${n1}${n2}${n3}${n4}${n5}${n6}${n7} 7 = "0" ]]; then
if [[ test ${n1}${n2}${n3}${n4}${n5}${n6}${n7}${n8} 8 = "0" ]]; then
if [[ test ${n1}${n2}${n3}${n4}${n5}${n6}${n7}${n8}${n9} 9 = "0" ]]; then
echo ${n1}${n2}${n3}${n4}${n5}${n6}${n7}${n8}${n9}
fi
fi
fi
fi
fi
fi
fi
fi
fi
done
done
done
done
done
done
done
done
done
Wow! ๐ฏ
I'm not sure what's duller, the question, the script, or the answer...
Bah, code is too easy, especially inelegant brute forcing it, and in bash as well... yuk. ๐
I'm pretty sure I was on the right lines for solving it by hand. It's easy enough to take those possible three digit numbers and see which are divisible by four when 2,4,6 or 8 is appended.
As beej points out, only 2 and 6 work since the last digit is odd. So...
1232 1236
1292 1296
1472 1476
1832 1836
1892 1896
3212 3216
3272 3276
3812 3816
3872 3876
7232 7236
7292 7296
7472 7476
7832 7836
7892 7896
9212 9216
9272 9276
9812 9816
9872 9876
Then eliminate the ones with repeated digits leaves:
[s]1232[/s] 1236
[s]1292[/s] 1296
1472 1476
1832 1836
1892 1896
[s]3212[/s] 3216
[s]3272[/s] 3276
3812 3816
3872 3876
[s]7232[/s] 7236
[s]7292[/s] 7296
[s]7472[/s] [s]7476[/s]
7832 7836
7892 7896
[s]9212[/s] 9216
[s]9272[/s] 9276
9812 9816
9872 9876
Then they can all have 5 appended and we're half way there..

